How to properly manage multiple versions of dotnet SDKs

oracle 0133 25 Reputation points

I have to build an F# project which requires dotnet 7.0.201. I have dotnet 7.0.302 globally installed.

The command could not be loaded, possibly because: 
  * You intended to execute a .NET application: 
      The application 'run' does not exist. 
  * You intended to execute a .NET SDK command: 
      A compatible .NET SDK was not found. 
Requested SDK version: 7.0.201 
global.json file: C:\Users\oracl\Documents\Programs\FsAutoComplete\global.json 
Installed SDKs: 
7.0.302 [C:\Program Files\dotnet\sdk] 
Install the [7.0.201] .NET SDK or update [C:\Users\oracl\Documents\Programs\FsAutoComplete\global.json] to match an installed SDK.  

I tried to use the install script given by MS and successfully installed version 7.0.201. However, the script places the SDK in


The original installed dotnet is in

C:\Program Files\dotnet\

I could change the install directory by assigning -InstallDir

.\dotnet-install.ps1 -Version "7.0.201" -InstallDir "C:\Program Files\dotnet"

However, I wonder if this would corrupt original installed dotnet (including all system-wide runtime, SDK 7.0.302). What's more, I wonder if adding to dotnet to the PATH together would disturb other applications which uses dotnet runtime or SDK. Is there a proper way to maintain multiple versions of dotnet SDKs while not corrupting anything?

Microsoft Technologies based on the .NET software framework.
3,609 questions
0 comments No comments
{count} vote

Accepted answer
  1. Wenbin Geng 716 Reputation points Microsoft Vendor

    Hi @oracle 0133 , Welcome to Microsoft Q&A.

    If you want to migrate the installation path of dotnet SDK 7.0.201, together with other dotnet SDK versions, then you should migrate to "C:\Program Files\dotnet\sdk" (not only the installation path changes, but also the Windows registration table has also changed). Here are two dotnet SDKs on my computer at the same time:

    User's image

    At this time, the dotnet in the system environment variable path is "C:\Program Files\dotnet". At this time, there are two versions of dotnet SDK under this path. At this time, you open CMD and enter "dotnet --version" and you will find that the result is a newer dotnet SDK version. Because there are two versions of dotnet SDK under this path, the system will recognize the dotnet SDK with a newer version number by default.

    At this point, if you want to specify the dotnet SDK version for the project, you can do the following:

    Open cmd in the root directory of the project and execute the command:

    dotnet new globaljson --sdk-version "sdk version number" --force

    Here is my example:

    User's image

    Best Regards,


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.  

    3 people found this answer helpful.

0 additional answers

Sort by: Most helpful