11

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?

Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467

1 Answers1

13

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" }
}
svick
  • 236,525
  • 50
  • 385
  • 514
  • Hint about "current directory" was a life savior for me since I am using out of the source tree building. Where did you find this information? – jariq Apr 03 '17 at 19:01
  • 2
    @jariq [You should be able to find it in the official documentation about global.json soon.](https://github.com/dotnet/docs/pull/1839) – svick Apr 04 '17 at 11:05