19

I just upgraded my visual studio 2019 to latest version 16.8.3 and suddenly I am not able to load any C# project and getting the following error for all .NET core projects:

The project file cannot be opened. Unable to locate the .NET SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.

mj1313
  • 6,367
  • 1
  • 2
  • 22
Dadwals
  • 451
  • 4
  • 13
  • 2
    Do you perhaps have a global.json file somewhere in the file system (in a common folder beneath all your failing projects) that is specifying an SDK version that no longer exists on your computer? If so: try renaming/deleting that file! (To be fair, the error message did suggest this) – Marc Gravell Dec 09 '20 at 07:27

4 Answers4

45

Try to edit envrionment Variables.

Right click on This PC -> Properties -> Advanced System Settings -> Advanced -> Environment Variables -> System Variables

Add [install path] C:\Program Files\dotnet\ to the variable path.

Restart visual studio.

If it does not solve this problem, you can refer to this answer.

Karney.
  • 2,881
  • 1
  • 4
  • 8
17

I found that the path C:\Program Files\dotnet was already in my path but it was ordered below the C:\Program Files (x86)\dotnet entry. By simply moving C:\Program Files\dotnet above C:\Program Files (x86)\dotnet in the list and restarting Visual Studio cleared up the problem.

stidhat
  • 181
  • 4
1

If there is a global.json file in your solution folder(where *.sln file reside), delete this. Problem solved for me.

Ahmet Arslan
  • 3,649
  • 1
  • 23
  • 29
0

This works for me... Check first if which .net Core SDK is available in the system.

Step 1: Open Command prompt (CMD) and type dotnet --info

enter image description here

The above image shows no SDK is installed or register

Step 2: Install SDK from https://dotnet.microsoft.com/download/dotnet-core

Done Visual studio works like charm... Verify if its properly installed and register

enter image description here

Above image you can see .net core SDK is registered properly on the system.

Krunal Solanki
  • 411
  • 4
  • 10