Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make dotnet core select a lower version?

I have several versions of dotnet core in my system. But .Net Core project selects the latest version for building the project. Is there anything I can do to make sure that the project selects the correct version? I am using Visual Studio for development.

like image 572
StarLord Avatar asked Sep 14 '25 05:09

StarLord


1 Answers

To list all the versions of dotnet core installed in the system, open the command prompt and type the following command:

dotnet --info

If you want to know the specific version used for running the application, go to the folder location, and type cmd in the address bar at the top to open command prompt. Then type this in command prompt.

dotnet --version

If you want to change this version to some other version installed in the system, type the following in the command prompt.

dotnet new globaljson --sdk-version 2.2.100 --force

Here, I want to use 2.2.100. This will create a global.json file. This will tell Visual Studio which version of .NET Core to use.

This is the content of global.json file.

{
  "sdk": {
    "version": "2.2.100"
  }
}

By following this, you can switch between .NET Core versions. Otherwise, Visual Studio will only take the latest version installed.

Further Reading:

  • dotnet command
  • dotnet new command
like image 178
StarLord Avatar answered Sep 15 '25 21:09

StarLord