baruchiro
baruchiro

Reputation: 5801

dotnet SDK 2.2.104 don't compile .NET Core 2.2

  1. I have a .NET Sdk version 2.1 and lower.
  2. I installed sdk2.2 and sdk3.
  3. I removed sdk3

Now, the VS17 build and test my solution successfully.

But from the command line, with dotnet-cli, I can't compile the solution, because he says he is sdk2.1.

dotnet build:

C:\Program Files\dotnet\sdk\2.1.500\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 2.2.  Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.2. [C:\Users\.......\WebApi.csproj]

Build FAILED.

dotnet --info:

.NET Core SDK (reflecting any global.json):
 Version:   2.2.104
 Commit:    73f036d4ac

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.104\

Host (useful for support):
  Version: 2.2.2
  Commit:  a4fd7b2c84

.NET Core SDKs installed:
  2.1.500 [C:\Program Files\dotnet\sdk]
  2.2.104 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

WebApi.csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    .
    .
    .
  </PropertyGroup>
</Project>

Upvotes: 0

Views: 1663

Answers (1)

baruchiro
baruchiro

Reputation: 5801

Thanks to livarcocc, we know the issue is in MSBuildSDKsPath environment variable, who still points to sdk2.1.

For fix the problem, we need to retarget the MSBuildSDKsPath to the SDK version we want, or completely remove this variable.

Before:

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

After:

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

Upvotes: 2

Related Questions