4
votes

dotnet msbuild

from the sln directory works

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe

from the solution directory works

I don't want VS 2017 to have to be installed on a build machine, so I installed "Build Tools for Visual Studio 2017" from https://www.visualstudio.com/downloads/.

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe

bombs out on every single project in the sln with the error:

error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

In truth - it doesn't exist on disk. It only exists in the VS subfolder at

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks

I have manually tried installing the .NET 4.6 SDK, the .NET Core 1.0 SDK, and .NET Core 1.0.1 SDK (both x86 and x64 versions).

Is there any way to make MSBuild function correctly or is it just irrepairably broken like much else?

3

3 Answers

1
votes

The only way I found now is to create a compile configuration where I target all the .NetCore and .net Standard projects and an other for all .Net projects (or simply use the release config).

Then I use MsBuild twice to build.

MSBuild.exe MySolution.sln /p:Configuration=DotNetCore

MSBuild.exe MySolution.sln /p:Configuration=Release

It works for VS2017 solutions.

1
votes

Copy the sdks folder from the dotnet core install to the msbuild tools install directory.

0
votes

The Build Tools installer does not currently support .NET Core workloads. At the moment, you must install Visual Studio on your build machines (or, as you note, install the .NET Core SDK and invoke dotnet msbuild instead of msbuild.exe).

This issue is tracked in MSBuild's GitHub repository: https://github.com/Microsoft/msbuild/issues/1697.