Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
460 views
in Technique[技术] by (71.8m points)

c# - The current .NET SDK does not support targeting .NET Core 2.2. (SDK 2.2.202)

Another one of those many many similar issues, yet none of the solutions searched for, helped (see below which one are looked at).

At the moment of writing this, .NET Core v2.2 is out of preview, the latest version being v2.2.202 (release date, 02-04-2019).

I installed that one via "Install other frameworks", I installed the x64 one, all other versions I have installed earlier are also that version.

After installing, when I create a new project, it shows up:

enter image description here

But when I then open the properties, it does not:

enter image description here

enter image description here

dotnet --info within the directory of the project, gives the following result:

.NET Core SDK (reflecting any global.json):
 Version:   2.2.202
 Commit:    8a7ff6789d

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:Program Filesdotnetsdk2.2.202

Host (useful for support):
  Version: 2.2.3
  Commit:  6b8ad509b6

.NET Core SDKs installed:
  2.1.2 [C:Program Filesdotnetsdk]
  2.1.4 [C:Program Filesdotnetsdk]
  2.1.201 [C:Program Filesdotnetsdk]
  2.1.202 [C:Program Filesdotnetsdk]
  2.1.401 [C:Program Filesdotnetsdk]
  2.1.505 [C:Program Filesdotnetsdk]
  2.2.202 [C:Program Filesdotnetsdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.3 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.3 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.3 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
  Microsoft.NETCore.App 2.0.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
  Microsoft.NETCore.App 2.1.3-servicing-26724-03 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
  Microsoft.NETCore.App 2.2.3 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

I have tried:

  • Create a global.json (SO answer), this only produced more errors as it could not load the project that is targeting v2.2
  • Enable preview SDKs within Settings (SO answer)
  • I have tried installing the x86 version, but that gave also more errors as it was confused about which one to use now. So that started complaining about .NET Standard not being installed.
  • I have updated Visual Studio and Visual Studio Build Tools to the latest versions, which is 15.9.11 (release date, 02-04-2019)
  • When I build via the command line dotnet build in the solution directory, it builds successfully, so it must be a visual studio thing.
  • verified that only C:Program Filesdotnet is in the Environment Variables, so C:Program Files (x86)dotnet is not present.
  • Looked at these options, did all of them but I did not set the MSBuildSDKsPath environment variable since I have other projects also in need with 2.1. I checked that there is currently no MSBuildSDKsPath set so it should not be forced to that version.

enter image description here

All of the above attempts of course involving restarting the computer or restarting VS.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This most likely looks like an installer optimisation for VS that removes old SDKs being too greedy and remove versions that older VS versions rely on, but at the moment this is more of an hypothesis while MS teams are investigating. See this GitHub issue for more similar reports.

The 2.2.1xx SDK(!) versions use MSBuild 15 and the 2.2.2xx use MSBuild 16.

VS 2017 needs to resolve a local version that is compatible with MSBuild 15 so if 2.2.1xx was removed during an upgrade, this may fail.

You can fix this by re-installing a compatible version - e.g. 2.2.105 - from https://dotnet.microsoft.com/download/dotnet-core/2.2

In order to find out which SDK uses which components, you can check the DependencyVersions.props file in the <3.0 sources and the Versions.props file for >= 3.0 (preview) sources - MSBuild version is set in via the MicrosoftBuildPackageVersion property.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...