Set Default Dotnet SDK Version

Sometimes when developing applications, we need to “lockdown” the SDK version and not use the latest version installed on the machine.

Global.Json

Using the .NET global.json file, we can set the default SDK version and instruct the compiler to use the set version.

To create a global.json file, you could use the following dotnet cli command (run it inside your project directory).

dotnet new globaljson

In my case, I am going to set the application to use .NET version 6.0.301

{
  "sdk": {
    "version": "6.0.301"
  }
}

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.