Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to locate the .NET SDK as specified by global.json, please check that the specified version is installed

Tags:

c#

.net

vb.net

f#

trying to start a .NET console application. Would prefer F# but get the same error in C# or VB as well.

Unable to locate the .NET SDK as specified by global.json, please check that the specified version is installed. I get that warning as soon as I create a new application, and get it as an error when I try to build.

This is using the default Hello World templates that come with Visual Studio. I would expect the prebuilt templates that ship with the app to build first time. Using VS 2019 16.8.5.

I have searched Visual Studio project and the source directory and can't find any global.json.

The errors

EDIT: Found the global.json at C:\users\username

{
  "sdk": {
    "version": "3.1.300",
    "rollForward": "latestMinor"
  }
}

Which I'm fairly sure I have the SDK installed for but will double check.

like image 934
Josh Avatar asked Aug 30 '25 14:08

Josh


2 Answers

In my case my global.json was referring to an SDK I didn't have. Run the below in your terminal

dotnet --list-sdks

That will give you the list of all the SDK's available, here you can either update your global.json file to the version you have (or install the missing SDK if you need to)

like image 136
Ricky Gummadi Avatar answered Sep 02 '25 05:09

Ricky Gummadi


I fixed this problem after discovering a global.json file at the directory root of a C# solution. This json file specified a specific sub version of .Net 7, after deleting the solution-level global.json the build error was solved.

Additional Info: This problem occurred for me after cloning a GitHub repository on my local PC. The C# repository contained two solutions and the problem global.json file was declared at the common directory root of the two solutions but it was not visible in the VS2022 solution explorer.

like image 33
camelCase Avatar answered Sep 02 '25 03:09

camelCase