我有.net应用,并且正在尝试从
从package.config到project.json.
当我使用Vs 2015构建项目或从命令行手动使用MsBuild时,一切正常.当我使用安装程序在构建服务器上构建它时,问题开始发生:
> .NET 4.51应用
> MSBuild 14.0.25402.0
> Windows Server 2012
>已安装Microsoft Build Tools 2013、2015 RC.
>未安装Visual Studio.
> Nuget 3.4.3.855
在创建nuget restore时,正在创建project.lock.json,程序包会下载到user / .nuget / packages中,因此看起来很正常.然后,我尝试运行MSBuild,并且遇到很多参考错误:
error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)
当我从开发人员机器上使用MSBuild时,即使指向服务器目录也可以构建该项目,因此MSBuild显然是一个问题.我想Microsoft Build Tools缺少什么,有什么主意吗?
编辑:
看起来msbuild在我的开发人员机器上的所有nuget路径中添加了标记/ reference,而在构建服务器机器上却没有这样做.
例:
/reference:C:\Users\user\.nuget\packages\log4net\1.2.10\lib\log4net.dll
开发人员构建项目的机器:
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
生成服务器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"
这只是日志的一部分->如您所见/ reference被传递到第一个脚本
解决方法:
我找到了解决方案.
如果缺少内容,将内容从开发人员机器复制到构建服务器机器上的相应目录.
C:\Program Files (x86)\MSBuild\Microsoft\NuGet
不知道为什么在构建工具2015安装后会丢失此内容.