Unable to locate the .NET SDK: The Reasons

The other day after installing some windows update, I tried to open Visual Studio. I opened my project and I received an error regarding .Net Sdk.

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.

It was kind of frustrating because I didn’t install anything new I just installed some windows update. Also this can happen for different reasons. So I thought this made me pull my own hair out, maybe by sharing this you don’t have to go through the same.

The .Net Sdk Is Not Actually Installed

First things first, removing some low hanging fruits. First wee need to see if the Sdk is actually installed. Navigate to C:\Program Files\dotnet\sdk and see if you can find folders associated with different sdk versions. If you can’t find any folder there that means the sdk is not installed. In that case Install the sdk or repair it if you receive a message about it being already installed. Try running dotnet --list-sdks command to see if it lists the sdk.

The .Net Sdk Is Installed But it Has Wrong System Type

The thing about the Sdk is that you can’t mix 64x with 86x versions of the sdk. Technically you can but you need to be careful which version of dotnet is going to be selected first. More on this in next section. But if an sdk is installed, be careful you have the correct system type.

The .Net Sdk is Installed But Wrong Dotnet CLI is Trying to Run It

Sometimes you check your dotnet sdk folder and you see the sdk are installed. But when you run dotnet --list-sdks you don’t see anything. In that case try running list-sdks command with an absolute path to the correct version of dotnet. Like C:\Program Files\dotnet  dotnet –list-sdks, if after running this you see the installed sdk then there are some path problems. You need to check your environment variables to make sure the correct version of dotnet is on your path. More on that in next section.

Dotnet CLI is Not on Your Path (System’s Environment Variable)

We need to first see how dotnet CLI is selected to run our commands. Take a look at this environment variables.

We see here that x64 version of the dotnet is above the x86 version of it. That means the x64 version is going to be selected to run my commands. So now if I only install the x86 version of the sdks, I’m going to have a problem. Because the x64 version of dotnet is unable to use the x86 sdks. What I need to do is to either install the x64 version of the sdk or move the x86 version above x64 version so it can be selected first.

Further Reading and References

Dotnet list-sdks does not list the installed SDKs

Microsoft Visual Studio 2019: The project file cannot be opened. Unable to locate the .NET SDK

.NET SDK not found after successful install

“No SDKs were found” after install “dotnet-hosting-2.1.2-win.exe”

Adventures in .NET Core SDK Installation: Missing SDKs and 32 bit vs 64 bit

Summary

In this post we saw why sometimes the correct sdk is not found on your system. We saw different things we can check for in these cases and how to fix them.

Share...
 

Hamid Mosalla

Hi, I'm Hamid Mosalla, I'm a software developer, indie cinema fan and a classical music aficionado. Here I write about my experiences mostly related to web development and .Net.

 

8 thoughts on “Unable to locate the .NET SDK: The Reasons

  1. Hi, great article!

    When you tell to use an absolute path to the correct version of dotnet, you write a command that does not work. It should be “C:\Program Files\dotnet\dotnet” –list-sdks. Please also apply the code style formatting.

  2. I am getting the below error after installing dotnet sdk version 6.

    “The project file cannot be opened. Version 6.0.310 of the .NET SDK requires at least version 17.0.0 of MSBuild. The current available version of MSBuild is 16.11.2.50704. Change the .NET SDK specified in global.json to an older version that requires the MSBuild version currently available.”

  3. God bless you. 3 days of repairing, uninstalling and installing frameworks, IDEs and other sundries to finally stumble upon this and found an old path variable that was causing the problem.

  4. Hi I am having a hard time with installing the current .Net SDK 8.0.100 for windows x64, after installing the said SDK and after I go to CMD to search for dotnet –version it gives me an error saying that dotnet is not recognized as internal or external command. even after doing multiple installs and checking the environment and system variables I can clearly see that the path is already there but the dotnet.exe file is missing from the C:ProgramFiles/dotnet folder and hence I am stuck in this deadlock. Please suggest something.

    1. Sorry to hear you’re having problems. You said you’ve installed the x64 version and then the dotnet is missing, are you sure you’re installing the correct version for your architecture ? Perhaps it’s x86 version

  5. Thanks a lot for this help:

    — either install the x64 version of the sdk
    — or move the x86 version above x64 version

    and over!

Leave a Reply

Your email address will not be published. Required fields are marked *