Search code examples
dotnet-cli.net-core

Choose the SDK version (e.g. preview3 vs preview2) that the dotnet CLI uses


We have three versions of the dotnet command line interface installed:

C:\Program Files\dotnet\sdk> dir -name
1.0.0-preview2-003133          
1.0.0-preview2-1-003177        
1.0.0-preview3-004056          

How can we choose which version to use when running for instance dotnet restore? Right now the version is always the preview3 build.

Our PATH contains C:\Program Files\dotnet\ which contains:

host                           
sdk                            
shared                         
swidtag                        
dotnet.exe                     
LICENSE.txt                    
ThirdPartyNotices.txt          

How do we choose which SDK the dotnet.exe uses?


Solution

  • You choose which CLI you use by placing a global.json file into the current directory or a directory above it.

    For example, to select 1.0.0-preview2-003133, the file would look like this:

    {
      "sdk": { "version": "1.0.0-preview2-003133" }
    }