2017-06-07 231 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)