Abdulkarim Kanaan
Abdulkarim Kanaan

Reputation: 1763

how to call a specific dotnet core version

I have installed two dotnet core versions i.e. 2.2 & 3.0 Preview.

2.2.103 [C:\Program Files\dotnet\sdk]
2.2.300 [C:\Program Files\dotnet\sdk]
3.0.100-preview-010184 [C:\Program Files\dotnet\sdk]

I need to make a call in the command prompt to a specific dotnet core version. for instance, dotnet new console --version?? How to do that? I don't need to create a project and then to change in csproj or global.json to a spcific version, but I need that on the command prompt level?

Upvotes: 0

Views: 750

Answers (2)

Neville Nazerane
Neville Nazerane

Reputation: 7049

Changing it in global.json is the way to set the current runtime version in terms of what you are trying to do. Even if there were a way in the command level it should only create a global.json file with the same configuration and then make the new app. The reason I say "should" is because there is already a way to do this, it wouldn't make sense to have a second way.

If updating the global.json file and then creating new projects doesn't work for you, then that is the bug you need to focus on fixing. I wouldn't advise trying to move away from global.josn. I have just tested this out. The generated templates are based on the respective version. If this isn't working, update your question with the exact errors.

Upvotes: 0

natemcmaster
natemcmaster

Reputation: 26823

Currently, the only way to control this is by creating a global.json file. When I need to do this, I run dotnet new globaljson and then edit the SDK version in the file.

Upvotes: 1

Related Questions