2017-06-07 232 views
0

我在Jenkins中创建了一个新项目。 当我尝试建立它,我得到以下错误:Jenkins构建失败 - 缺少文件Microsoft.Build.Utilities.Core

"E:\Jenkins\workspace\MWAPIv1\My.WebAPIv1.sln" (default target) (1) -> "E:\Jenkins\workspace\MWAPIv1\My.WebAPIv1\My.WebAPIv1.csproj" (default target) (2) -> (CoreCompile target) -> C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets(316,9): error MSB4062: The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly E:\Jenkins\workspace\MWAPIv1\packages\Microsoft.Net.Compilers.2.2.0\build..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [E:\Jenkins\workspace\MWAPIv1\My.WebAPIv1\My.WebAPIv1.csproj]

该项目采用NET框架4.5.2。

一些其他可能有用的信息: 由于错误提到丢失dll,我检查了所有文件,包括包文件夹和内容到SVN,但这没有帮助。 我也更新了VS2015中的所有Nuget包并检入了更新。 在詹金斯的项目配置为: MSBuild Version: Microsoft.NET Framework v4.0 MSBuild Build File: My.WebAPIv1.sln Command Line Arguments: /p:VisualStudioVersion=14.0

下列文件夹存在于我的詹金斯服务器:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v9.0

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0

任何想法如何让我的项目建设?

感谢

+0

你试过了Martin的建议吗?他的回答对你有帮助吗?如果没有,请让我们知道这个问题的最新状态。 –

+0

对于我来说这个问题的解决方案是删除两个nuget包:'Microsoft.Net.Compilers'和'Microsoft.CodeDom.Providers.DotNetCompilerPlatform'然后签入。然后在Jenkins中构建好。但是,我遇到了与MVC项目相同的问题,并删除上述包导致我的项目提供500错误页面。我会为此尝试Martins解决方案。 – cdsln

回答

1

你建立一个使用.NET Framework提供的MSBuild的版本(4.0.30319),这是很旧,有不同的体系结构,该Microsoft.Net.Compilers NuGet包预期,您似乎使用运行覆盖旧的构建目标以使用更新的编译器。

使用MSBuild的较新版本来完成此工作,例如,由VS 2015安装的那个在C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe(替代方法:安装并使用“构建视觉工作室的工具”2015或2017)