I recently installed VS 2017 RC and then automatically my dotnet version pointed to 1.0.0-preview4-004233. Due to that whenever I create a new project using com
You can do this with a global.json file in the root of your project:
dotnet --list-sdks
You'll see a list like this.
2.1.100 [C:\Program Files\dotnet\sdk]
2.1.101 [C:\Program Files\dotnet\sdk]
2.1.103 [C:\Program Files\dotnet\sdk]
2.1.104 [C:\Program Files\dotnet\sdk]
[...lines omitted...]
2.1.601 [C:\Program Files\dotnet\sdk]
2.2.101 [C:\Program Files\dotnet\sdk]
3.0.100-preview3-010431 [C:\Program Files\dotnet\sdk]
dotnet new.dotnet new globaljsonThe result will look something like this:
{
"sdk": {
"version": "3.0.100-preview3-010431"
}
}
version, replace the 3.0.100-preview3-010431 with the version you prefer from the --list-sdks list. For example:{
"sdk": {
"version": "2.2.101"
}
}
dotnet --version to verify. You should see:2.2.101
dotnet new commands to create your project.Dotnet usually uses the latest SDK version, unless it finds a global.json file that tells it to do otherwise. The explanation by microsoft
dotnet looks for the file in the working directory (not necessarily the project or solution directory), and if it can't find one it starts searching upwards from there. documentation
An easy way to create a global.json file would be to run dotnet new globaljson --sdk-version 1.0.0-preview2-003133 in the directory of your project.
create a global.json from the cli