Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing include for .NetStandard project when building on build server

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.

like image 266
Anders Avatar asked Mar 16 '17 14:03

Anders


2 Answers

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
like image 182
Spongman Avatar answered Sep 30 '22 02:09

Spongman


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.

like image 22
TeraTon Avatar answered Sep 30 '22 03:09

TeraTon