Search code examples
.net-corebuild

How to change the dotnet SDK version for the particular build?


I have both dotnet SDK 6 (6.0.101) and 5 (5.0.406) installed. So when I build the code SDK 6 is used. I would like to check if my changes would build cleanly when SDK 5 is used. I do not want to uninstall SDK 6. Is it possible to instruct the particular command line build to use SDK 5?


Solution

  • How dotnet picks a .NET SDK version is explained at Select the .NET version to use.

    To use the specific SDK version, add global.json file to the root of your solution or a project with the settings:

    {
      "sdk": {
        "version": "5.0.406"
      }
    }