1
votes

I've set up a new project in Jenkins. When I try to build it I get the following error:

"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]

The project uses NET 4.5.2 Framework.

Some other possibly useful information: Since the error mentions missing dlls, I checked in all files, including the packages folder and contents to SVN, but this didn't help. I also updated all Nuget packages from within VS2015 and checked in any updates. The project configuration in Jenkins is: MSBuild Version: Microsoft.NET Framework v4.0 MSBuild Build File: My.WebAPIv1.sln Command Line Arguments: /p:VisualStudioVersion=14.0

The following folders exist in my Jenkins server:

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

Any ideas how to get my project to build?

Thanks

1
have you tried the Martin`s suggestion? Does his answer help you? If not, please let us to know the latest status of this question.Leo Liu-MSFT
The resolution to this particular question for me was to remove two nuget packages: Microsoft.Net.Compilers and Microsoft.CodeDom.Providers.DotNetCompilerPlatform then check in. This then built okay in Jenkins. However I am experiencing the same issue with an MVC project and removing the above packages cause my project to deliver a 500 error page. I will try Martins solution for this.cdsln

1 Answers

2
votes

Your build is running using the .net framework provided version of MSBuild (4.0.30319), which is quite old and has a different architecture that the Microsoft.Net.Compilers NuGet package expects, which you seem to use to override the old build targets to use a newer compiler.

Use a newer version of MSBuild for this to work, e.g. the one installed by VS 2015 at C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe (alternative: install and use the "build tools for visual studio" 2015 or 2017)