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
388 views
in Technique[技术] by (71.8m points)

asp.net - The current .NET SDK does not support targeting .NET Core 3.0 | 3.1 | 5.0

I've just downloaded the release version of .NET Core 3.0.100
It was installed alongside older version that I have:

enter image description here

When I try to run dotnet restore for a project that targets .NET Core 3 (<TargetFramework>netcoreapp3.0</TargetFramework>), I get this error

C:Program Filesdotnetsdk2.2.202SdksMicrosoft.NET.SdkargetsMicrosoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.0.  Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.0.

I have a global.json file that explicitly states that I need the 3.0.100 SDK

{
  "sdk": {
    "version": "3.0.100"
  }
}

I know that I can edit the MSBuildSDKsPath env variable to point to the 3.0.100 SDK, and it works, but I don't want to do it, I have other projects on my machine that still need to use older versions of .NET Core.

Is there a way to make the dotnet tool use the SDK that's stated in global.json instead of the one in MSBuildSDKsPath?

Edit: I use Visual Studio Code

question from:https://stackoverflow.com/questions/58074709/the-current-net-sdk-does-not-support-targeting-net-core-3-0-3-1-5-0

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

1 Reply

0 votes
by (71.8m points)

You also have to update your visual studio to the minimum supported version:

.NET Core 3.0

  • minimum visual studio v16.3

.NET Core 3.1

  • minimum visual studio v16.5

.NET Core 5.0

  • minimum visual studio v16.6 latest preview

enter image description here

(https://dotnet.microsoft.com/download/dotnet-core/3.0)


![enter image description here

(https://dotnet.microsoft.com/download/dotnet-core/3.1)


enter image description here

(https://dotnet.microsoft.com/download/dotnet/5.0)


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

...