How to install multiple versions of .NET Core side by side on Linux

Written by M.Hossein S.Farvashani on May 24th, 2021 Views Report Post

There was so many times that I need to install more than one dotnet core sdks on my linux machine but i could not find any decent solution for that. I always knew that there should be a straightforward way to install multiple sdks because of dotnet --list-sdks command which suppose to display a list of sdks.

the solution was too easy to imagine just download the tar.gz package from https://dotnet.microsoft.com/download/dotnet and fallow the instruction on that page which is :

mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-6.0.100-preview.3.21202.5-linux-x64.tar.gz -C $HOME/dotnet
export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet

after that you can test the installation by runing

dotnet --list-sdks

and the result would be something like this


> dotnet --list-sdks 
5.0.203 [/home/me/dotnet/sdk]
6.0.100-preview.3.21202.5 [/home/me/dotnet/sdk]

you can switch beetwen sdks versions by creating global.json in the root of your project.

dotnet new globaljson --sdk-version 5.0.203

which create a json file

{
  "sdk": {
    "version": "5.0.203"
  }
}

that is it.

Comments (0)