.netvisual-studioasp.net-core

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.


Solution

  • 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: