简体   繁体   English

无法构建带有project.json的.NET项目

[英].NET project with project.json cannot be built

I have .net app, and I am trying to migrate from 我有.net应用程序,我正在尝试从中迁移

packages.config to project.json . packages.configproject.json

Everything works fine when I build the project with Vs 2015 or manually using MsBuild from a command line. 当我使用Vs 2015构建项目或从命令行手动使用MsBuild时,一切正常。 The problem starts to happen when I build it on build server with the setup: 当我使用设置在构建服务器上构建时,问题就开始发生了:

  1. .NET 4.51 app .NET 4.51应用程序
  2. MSBuild 14.0.25402.0 MSBuild 14.0.25402.0
  3. Windows Server 2012 Windows Server 2012
  4. Microsoft Build Tools 2013, 2015 RC installed. 安装了Microsoft Build Tools 2013,2015 RC。
  5. No Visual Studio installed. 没有安装Visual Studio。
  6. Nuget 3.4.3.855 Nuget 3.4.3.855

When doing nuget restore project.lock.json is being created, packages are downloaded to user/.nuget/packages so it looks like it's doing the job. 当正在创建nuget restore project.lock.json时,将包下载到user / .nuget / packages,这样看起来它正在完成这项工作。 Then I am trying to run MSBuild, and I am getting a lot of reference errors: 然后我试图运行MSBuild,我收到很多引用错误:

error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)

When I use MSBuild from developer machine, I can build this project even if I point to build server directory so it's an obvious problem with MSBuild. 当我从开发人员机器使用MSBuild时,即使我指向构建服务器目录,我也可以构建这个项目,因此这是MSBuild的一个明显问题。 I suppose that something is missing with Microsoft Build Tools, any ideas? 我想微软构建工具缺少一些东西,任何想法?

Edit: it looks like msbuild adds flag /reference with all nuget paths on my developer machine and it doesn't do it on build server machine. 编辑:看起来msbuild在我的开发人员计算机上添加了所有nuget路径的标记/引用,并且在构建服务器计算机上没有这样做。 Example: 例:

 /reference:C:\Users\user\.nuget\packages\log4net\1.2.10\lib\log4net.dll

Developer machine building the project: 构建项目的开发者机器:

Build started 27/06/2016 13:29:40.
Project "Y:\13dd0660b4e0a7a0\project.Shared.Utilities\project.Shared.Utilities.csproj" on node 1 (default targets).
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
  C:\Program Files (x86)\MSBuild\14.0\bin\csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:C:\Users\username\.nuget\packages\EPPlus\4.0.4\lib\net20\EPPlus.dll

Build server msbuild building the same project 构建服务器msbuild构建同一个项目

D:\13dd0660b4e0a7a0\project.Shared.Utilities>"C:\Program Files (x86)"\MSBuild\14.0\Bin\msbuild project.shared.utilities.csproj
Microsoft (R) Build Engine version 14.0.25123.0
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 27/06/2016 12:35:19.
Project "D:\13dd0660b4e0a7a0\project.Shared.Utilities\project.shared.utilities.csproj" on node 1 (default targets).
PrepareForBuild:
  Creating directory "bin\Debug\".
  Creating directory "obj\Debug\".
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
  C:\Program Files (x86)\MSBuild\14.0\bin\csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.ComponentModel.DataAnnotations.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Configuration.dll" 

This is only part of the log -> as you can see /reference is passed to the first script 这只是日志的一部分 - >你可以看到/ reference被传递给第一个脚本

I have found the solution. 我找到了解决方案。 Copy content from developer machine to corresponding directory on your build server machine if missing. 如果缺少,将内容从开发人员计算机复制到构建服务器计算机上的相应目

C:\Program Files (x86)\MSBuild\Microsoft\NuGet

Not sure why this is missing after build tools 2015 installation. 在构建工具2015安装之后,不确定为什么会丢失它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM