How can I install two versions of .NET for Rider?

I have installed both Rider and dotnet-sdk with Snap, so that I can debug .NET projects. However, I now need to work on an older solution that runs on an older version of .NET.

How can I install another version of .NET and still work on both projects?


You can achieve this by installing two .NET snaps in parallel. Rider will detect both versions and you can pick one per solution.

If you have .NET already installed, uninstall it:

sudo snap remove dotnet-sdk
# this is to avoid confusion between versions

Enable parallel instances:

sudo snap set system experimental.parallel-instances=true
# see references for details

Now install both versions in parallel (we'll use 5.0 and 3.1 as examples), and create aliases:

sudo snap install --classic --unaliased dotnet-sdk_50 --channel=5.0/stable
sudo snap install --classic --unaliased dotnet-sdk_31 --channel=3.1/stable
sudo snap alias dotnet-sdk_50.dotnet dotnet50
sudo snap alias dotnet-sdk_31.dotnet dotnet31
# aliases picked based on Microsoft convention

When you next start Rider it will automatically detect all available versions. You can set your preference per solution, and/or set a default for new solutions.

.NET Core CLI executable path dropdown with both 3.1 and 5.0 visible

References

  • https://snapcraft.io/blog/parallel-installs-for-classic-snaps
  • https://docs.microsoft.com/en-us/dotnet/core/install/linux-snap