Reputation: 8750
I've got an ASP.NET Core project in my solution, targeting .NET Core 2.1. I've added a global.json file at the solution level:
{
"sdk": {
"version": "2.1.400"
}
}
On the Team City agent, I've installed MSBuild Tools 2017 (15.8.1), including .NET Core Build Tools.
From the command line I can see SDK 2.1.400 is installed on the agent:
>dotnet --list-sdks
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.400 [C:\Program Files\dotnet\sdk]
However, building the solution fails on Team City with the following error:
dashboard.csproj : error : Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.
Dashboard.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
A compatible SDK version for global.json version: [2.1.400] from [X:\agent-1\sandbox1\global.json] was not found
Any idea why it wouldn't find SDK 2.1.400 when building with MSBuild given it's present in the SDK list?
Upvotes: 2
Views: 3948
Reputation: 11
Verify that the PATH environment variable points to the location where the SDK is installed (C:\Program Files\dotnet\ for 64-bit/x64 or C:\Program Files (x86)\dotnet\ for 32-bit/x86). The SDK installer normally sets the PATH. Always install the same bitness SDKs and runtimes on the same machine.
Upvotes: 1
Reputation: 8750
I finally worked out that dotnet
was not recognised as a command when running on Team City (despite dotnet
being recognised as a command from the prompt, under the same Windows account).
The solution for me was to update the PATH
environment variable using Team City parameters:
Name: env.PATH
Kind: Environment Variable
Value: C:\Program Files\dotnet;%env.PATH%
It now works as expected.
Upvotes: 3