Reputation: 141
I have downloaded and install Visual Studio 2019 and have dotnet core 3.1 installed. As I am starting to play around with VS, I have just created a simple project using VS built-in Web App Template and try to run without debugging.
It gives the error of "The current .NET SDK does not support targeting .NET Core 3.1. Either target .NET Core 3.0 or lower, or use a version of the .NET SDK that supports .NET Core 3.1."
May I know how it can be resolved?
Thanks.
Regards, Andrew
Upvotes: 14
Views: 18036
Reputation: 27026
I am using VS 2022 and have a parallel installation of VS 2019 on my PC.
And I noticed that .NET 3.1 SDK (LTS) had to be installed (both 32 and 64 bit packages) to support an existing EF code first project (running with EF 3.x). Without it, the migration did not work and I got an error message like the one mentioned in the question.
Note that they can be installed in parallel with other versions (I have .NET 5 and .NET 6 on my PC installed as well).
You can find the required packages here: https://aka.ms/dotnet-download
Upvotes: 0
Reputation: 9
I was having vs 17 vs 19 both I was trying to open code developed in visual studio 2019 into 2017. Opening that project in VS 19 solved the issue for me
Upvotes: 0
Reputation: 1113
For me, it was an environment variable. Not sure what set it (maybe some lame chocolatey package or something.)
I had environment variable MSBuildSDKsPath
set as C:\Program Files\dotnet\sdk\2.0.3\Sdks
Removing that environment variable fixed the issue for me. (Actually, I renamed the environment variable to OLD_MSBuildSDKsPath
, just in case ;) )
Upvotes: 0
Reputation: 4729
If you already have VS 2019 version more then v16.4, then magicandre1981 answer will be helpful.
But, I would suggest you to check your VS version as well. as I have invested lots of hours and checked my version much later.
Minimum compatibility visual studio version for .net Core 3.1
is Visual Studio 2019 (v16.4)
. I updated it and it worked.
Release update: https://dotnet.microsoft.com/download/dotnet-core/3.1
Upvotes: 0
Reputation: 28836
If you already have the correct .NET Core 3.1 SDK installed it could be caused by a file called global.json
. This file allows to configure which SDK is used:
The global.json file allows you to define which .NET Core SDK version is used when you run .NET Core CLI commands. Selecting the .NET Core SDK is independent from specifying the runtime your project targets. The .NET Core SDK version indicates which versions of the .NET Core CLI is used.
Delete the file or change the defined SDK to 3.1:
{
"sdk": {
"version": "3.1.100",
"rollForward": "latestPatch",
"allowPrerelease": false
}
}
Upvotes: 13