Missing include for .NetStandard project when building on build server
Asked Answered
M

3

14

I'm currently trying out VS2017 at work, due to an interest in migrating our server systems to .Net core. I have switched a couple of minor tools projects to target .NetStandard 1.2 (recreate and move files), and everything builds locally.

However, when I request a build on our TeamCity 10.0.5 server, the build fails with the following message (Project name redacted):

E:\TeamCity\buildAgent1\work\467cb2a824afdbda\Source\{PROJECT FOLDER}\{PROJECT}.csproj 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.

The folder Microsoft.NET.Sdk does indeed exist on my machine, but not on the build server.

I have installed Build Tools for Visual Studio 2017, and installed .Net Core 1.1 SDK, and the build configuration uses a Visual Studio (sln) runner using VS2017.

What set of tools/installer am I missing?

UPDATE: I've experimented with the Full Visual Studio 2017 installer (community), and the package .NET Framework 4.5 Targeting Pack added the folder in question. Odd, since 4.5 Multi-Targeting pack is already installed on the server.

After setting Build agent to use a full VS2017 community install, a bunch of other issues appeared, such as System namespace not found in the projects in question.

Adding a dotnet restore build step fixed this issue, but then other namespaces where missing (missing installs), and so on.

Building a full framework solution with .NETStandard projects seems to rely on .NET Core to build, which I don't understand, since I'm not targeting .NET Core.

Magdalenemagdalenian answered 16/3, 2017 at 14:42 Comment(3)
I'm seeing the same problem. I guess the switch to .csproj is only half done?Lugworm
I have exactly the same problem. Copying the Sdks folder on the build server did not solve the problem. Installing .NET Core SDK also did not resolve the problem.Lambrequin
Related github msbuild issue : github.com/Microsoft/msbuild/issues/1697Lambrequin
M
5

I solved this issue by installing the .NET Core SDK and adding the MSBuildSDKsPath. I also copied the different SDKs from my local install of visual studio to the build server. As of now you have to install a full Visual Studio install to the server to get the build working without these stopgap fixes.

  1. install .NET Core SKD from here.

  2. Add MSBuildSDKsPath to environment variables in cmd.

    set MSBuildSDKsPath=C:\Program Files\dotnet\sdk\1.0.1\Sdks

  3. From your local enterprise or professional install of visual studio, copy needed sdk files to your ms build server. Copy the contents of this folder on your local Visual studio:

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

    To this folder on the build server:

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

  4. Follow the ticket for this bug in github to get notified when this problem with build tools is fixed.

Marvelmarvella answered 4/8, 2017 at 11:15 Comment(3)
Thank you @TeraTon. This is exactly what I ended up doing. Quite annoying with all the manual copying of assemblies. But whatever works. ☺️Magdalenemagdalenian
I am getting this issue now with Core 2+ The current .NET SDK does not support targeting .NET Core 2.0. Either target .NET Core 1.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.0Myotonia
I solved that error by copying the SDK target out of the \dotnet\SDKs directory into the \MSBuild\Sdks directory. Then I also had to make sure I was using NUGet 4+ in TeamCityMyotonia
L
9

try installing the .NET Core SDK from here: .NET Core Downloads

and, if necessary:

set MSBuildSDKsPath=C:\Program Files\dotnet\sdk\1.0.1\Sdks
Lugworm answered 16/3, 2017 at 22:12 Comment(2)
.NET Core SDK is installed. :)Magdalenemagdalenian
As of BuildTools 15.3 there is no need to set this variable anymore. The tools can find and use an installed SDK directly. Moreover, BuildTools no more contain its own private version of the SDK.Ectoparasite
M
5

I solved this issue by installing the .NET Core SDK and adding the MSBuildSDKsPath. I also copied the different SDKs from my local install of visual studio to the build server. As of now you have to install a full Visual Studio install to the server to get the build working without these stopgap fixes.

  1. install .NET Core SKD from here.

  2. Add MSBuildSDKsPath to environment variables in cmd.

    set MSBuildSDKsPath=C:\Program Files\dotnet\sdk\1.0.1\Sdks

  3. From your local enterprise or professional install of visual studio, copy needed sdk files to your ms build server. Copy the contents of this folder on your local Visual studio:

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

    To this folder on the build server:

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

  4. Follow the ticket for this bug in github to get notified when this problem with build tools is fixed.

Marvelmarvella answered 4/8, 2017 at 11:15 Comment(3)
Thank you @TeraTon. This is exactly what I ended up doing. Quite annoying with all the manual copying of assemblies. But whatever works. ☺️Magdalenemagdalenian
I am getting this issue now with Core 2+ The current .NET SDK does not support targeting .NET Core 2.0. Either target .NET Core 1.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.0Myotonia
I solved that error by copying the SDK target out of the \dotnet\SDKs directory into the \MSBuild\Sdks directory. Then I also had to make sure I was using NUGet 4+ in TeamCityMyotonia
M
1

If you use solution with SDK projects only so all of you need is that use dotnet restore && dotnet build instead of nuget restore & msbuild. But if it mixed solution (old projects and SDK projects) you will have to wait until VS15.3 is released

Matins answered 4/8, 2017 at 18:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.