Microsoft Visual Studio 2019: The project file cannot be opened. Unable to locate the .NET SDK
Solution 1
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.
Solution 2
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.
Solution 3
If there is a global.json file in your solution folder(where *.sln file reside), delete this.
Solution 4
In my case, I had .NET 6 preview but then uninstalled it. After uninstalling, some of my projects won't load. I have all the configurations mentioned above but still won't load the projects. I went to C:\Program Files\dotnet\sdk\ where I found that there still exist a .NET 6 folder which is empty. Deleting that empty .NET 6 folder fixes the issue and I was able to load my projects.
Solution 5
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
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
Above image you can see .net core SDK is registered properly on the system.
Comments
-
Dadwals almost 2 years
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.