1.0.0-rc3-004530
(via sudo apt-get install 1.0.0-rc3-004530
), dot-net
CLI defaults to 1.0.0-rc3-004530
. That means dotnet new
creates projects with .csproj
and MSBuild.1.0.0-preview2-1-003177
(with project.json
) and the other (I want to experiment) using 1.0.0-rc3-004530
.dotnet
CLI to use a specific SDK version when doing dotnet new
and other commands.Is there a way to choose the SDK version that dotnet CLI should use?
Thanks!
dotnet --info
output:
.NET Command Line Tools (1.0.0-rc3-004530)
Product Information:
Version: 1.0.0-rc3-004530
Commit SHA-1 hash: 10b642bc12
Runtime Environment:
OS Name: ubuntu
OS Version: 16.04
OS Platform: Linux
RID: ubuntu.16.04-x64
Base Path: /usr/share/dotnet/sdk/1.0.0-rc3-004530
How my dotnet folder looks like:
.
โโโ host
โย ย โโโ fxr
โย ย โโโ 1.0.1
โย ย โโโ 1.1.0
โโโ sdk
โย ย โโโ 1.0.0-preview2-1-003177
โย ย โย ย โโโ runtimes
โย ย โโโ 1.0.0-rc3-004530
โย ย โโโ 15.0
โย ย โโโ Extensions
โย ย โโโ Roslyn
โย ย โโโ runtimes
โย ย โโโ Sdks
โย ย โโโ Templates
โย ย โโโ TestHost
โโโ shared
โโโ Microsoft.NETCore.App
โโโ 1.0.3
โโโ 1.1.0
```
You can use a global.json like the one below. Put it in the root of your repo and if you run a dotnet command from a folder containing that file (or an child folder), that version will be respected.
{
"sdk": {
"version": "1.0.0-preview2-1-003177"
}
}
@livarcocc Thanks. I finally added the global.json
as you suggested.
However, I suppose my scenario was little different. My projects are still on sdk 1.0.0-preview2-1-003177. I am working on porting them in a phased manner to 1.0.0-rc3-004530, which is not yet released here.
While I continue to experiment with rc3, I would to continue create and work with preview2 style (project.json
) projects. I would like have both SDKs on my machine and choose which SDK to use.
For instance, during experimentation when I wanted to convert project.json
projects to .csproj
, dotnet migrate
was not working (not recognized) from within my projects folder (I had global.json
already before raising this issue here). I took a while for me to figure you have to be outside the project folder where there is no global.json
and so would be using the latest SDK version (rc3 in our case).
The other thing that was inconvenient to me is I cannot simply dotnet new
to create a project.json
project. I will have to create the global.json
first.
Just sharing my experience ...
Most helpful comment
You can use a global.json like the one below. Put it in the root of your repo and if you run a dotnet command from a folder containing that file (or an child folder), that version will be respected.