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

こ雲淡風輕ζ 提交于 2019-11-26 08:34:39

问题


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:

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

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 Files\\dotnet\\sdk\\2.2.202\\

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

.NET Core SDKs installed:
  2.1.2 [C:\\Program Files\\dotnet\\sdk]
  2.1.4 [C:\\Program Files\\dotnet\\sdk]
  2.1.201 [C:\\Program Files\\dotnet\\sdk]
  2.1.202 [C:\\Program Files\\dotnet\\sdk]
  2.1.401 [C:\\Program Files\\dotnet\\sdk]
  2.1.505 [C:\\Program Files\\dotnet\\sdk]
  2.2.202 [C:\\Program Files\\dotnet\\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.3 [C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.3 [C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.3 [C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.5 [C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.3-servicing-26724-03 [C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.3 [C:\\Program Files\\dotnet\\shared\\Microsoft.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 Files\\dotnet\\ 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.

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


回答1:


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.




回答2:


Adding @martin-ullrich's answer from https://github.com/aspnet/AspNetCore.Docs/issues/11844, because it made more sense to me. (Maybe 'cuz it's Friday, and I just needed: "Go here and do this.")

Go to https://dotnet.microsoft.com/download/dotnet-core/2.2 and download the installer for the 2.2.105 version. Anything >= 2.2.200 will not work in VS 2017. Both 2.2.105 and 2.2.202 contain the latest and greatest .NET Core 2.2 version but they differ in the version of the tools they include and are based on - the 1xx train is MSBuild 15., NuGet 4. etc. and the 2xx train is MSBuild 16., NuGet 5. and so on and Visual Studio only looks for the latest version compatible with its version of MSBuild - for VS 2017 this is 2.1.502 version which cannot target .NET Core 2.2. (And to add more confusion, there are now 2.1.6xx versions with VS 2019 tool versions together with the .NET Core 2.1 runtime)

[@]leecow and [@]rowanmiller are working on updating that page regarding VS, also see dotnet/core#2542 and dotnet/sdk#3076 which are about the same problem.


My contribution: After installing 2.2.105, I deleted the folder(s) titled '2.2.202' in directory C:\Program Files (x86)\dotnet\sdk and/or C:\Program Files\dotnet\sdk so that dotnet --info now reads the following:




回答3:


Installing dotnet-sdk-2.2.103-win-x64 fixed the issue




回答4:


Use Visual Studio 2019 instead of 2017 if you want work with asp.net core version more then v2.2.100 https://github.com/aspnet/AspNetCore.Docs/issues/11844




回答5:


If you are using Visual Studio 2017 (v15.9) you need to install .NET Core SDK version 2.2.108 as greater versions is supported only in Visual Studio 2019.

See the table below to select the correct download.

Check also release information and download links here



来源:https://stackoverflow.com/questions/55513335/the-current-net-sdk-does-not-support-targeting-net-core-2-2-sdk-2-2-202

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!