Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild of VS2017 cannot compile .NET Standard 2.0 project

I have a csproj which targets .NET framework 4.6.1 and .NET Standard 2.0.

It can be compiled in my local machine with Visual Studio 2017 (v15.3.2)

Now I am setting up our building server(Jenkins) to include this project. Our building server works fine for other .NET framework 4.6.1 projects.

First, I copied the toolchain from my local machine (C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\) to the building server.

Then I configured Jenkins to use the MSBuild v15.3.409.57025, which was copied from C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe

But it results in the following error on compilation

C:\Program Files (x86)\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(126,5): error : The current .NET SDK does not support targeting .NET Standard 2.0. Either target .NET Standard 1.6 or lower, or use a version of the .NET SDK that supports .NET Standard 2.0.

The file Microsoft.NET.TargetFrameworkInference.targets was also copied from my local machine C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets. I checked its content in my local machine and saw a line below.

<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

The ToolsVersion is still 14.0 in my VS2017 directory?

Does anyone know how to solve it?

Thanks

like image 540
Mr.Wang from Next Door Avatar asked Aug 31 '17 10:08

Mr.Wang from Next Door


1 Answers

You also need to install the .NET Core 2.0.0 SDK since the VS installation only includes the 1.1.0 tasks and targets and looks for other installed versions that are compatible with the current msbuild version (or there is a global.json file in the project that pins a different version).

like image 64
Martin Ullrich Avatar answered Oct 30 '22 03:10

Martin Ullrich