How to set the .NET Core SDK while using dotnet build

Nitin Manju
1 min readJun 2, 2021

If your development machine has multiple versions of .NET Core SDK installed, you might have run into a problem where the ‘dotnet build’ command uses the latest version of the SDK by default.

If you would like to set a version of the SDK to be the default for the project/repository, you could add a file ‘global.json’ within the main directory of the project and set the version of the .NET core SDK as shown below.

{
“sdk”: {
“version”: “3.0.0”
}
}

Now on executing the ‘dotnet build’ inside the project directory, the CLI should use the above version of the SDK by default.

Note: This article is a simplified, to the point extraction from here. Read to get more info. Get more information on dotnet build here.

The global.json file must be available within the root of the project directory. The dotnet CLI will automatically detect this file without any special instructions.

--

--