MSBuild of VS2017 cannot compile .NET Standard 2.0 project
Asked Answered
S

1

8

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

Semantics answered 31/8, 2017 at 10:48 Comment(3)
I doubt coping the VS installation folder is enough here - after all VS is not xcopy-deployable. If you can't, or don't want to, install VS on the build server, consider installing the Build Tools (for 2017) only.Cloutier
@Christian.K, copying MSBuild always works from my experience. I will try to install VS2017 on building server but I don't think that is the causeSemantics
The build tools now (15.3) have the necessary SDK resolver but lack the integrated NuGet support required for .NET Core/Standard projects, so a "full" version is still needed (until probably 15.4).Singspiel
S
8

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).

Singspiel answered 31/8, 2017 at 10:57 Comment(1)
Just for the sake of completeness: VS needs to be restarted after the installation of the SDK for everything to be correctly recognized.Moulden

© 2022 - 2024 — McMap. All rights reserved.