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

Posted on Feb 11, 2023

Question

We have an app, written in .NET Core rc2 running on an acceptance environment (linux server). Recently our client ran their own performance tests, which turned out to completely break the application. We couldn't reproduce it ourselves for several reasons:

  1. We develop on windows
  2. We have since migrated from rc2 to 1.0.0.

On windows, we couldn't reproduce in either our new version (1.0.0) or rc2. So we tried to reproduce it on a linux machine. on 1.0.0 we couldn't reproduce their results either, but when we tried to actually test against rc2 (an older version of our app, obviously) we ran into a really annoying problem: I don't seem to be able to install 1.0.0 and rc2 side by side, even though the error message implies it's possible. Below is the error message

The specified framework 'Microsoft.NETCore.App', version '1.0.0-rc2-3002702' was not found.
  - Check application dependencies and target a framework version installed at:
      /usr/share/dotnet/shared/Microsoft.NETCore.App
  - The following versions are installed:
      1.0.0
  - Alternatively, install the framework version '1.0.0-rc2-3002702'.

Basically, we want to be able to check the version currently running on acceptance of our app (rc2) on a linux machine, but we are struggling with actually getting rc2 on it.

Thanks. If anything is unclear, post your question in the comments.

EDIT: I tried building it as a standalone deployment, but then I get the following error:

Errors in /home/nicolaas/Projects/digipolis-survey-engine/Digipolis.FormEngine/Digipolis.FormEngine.Response.API/project.json
    System.AppContext 4.1.0-rc2-24027 provides a compile-time reference assembly for System.AppContext on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with ubuntu.15.10-x64.
    System.Runtime.InteropServices.RuntimeInformation 4.0.0-rc2-24027 provides a compile-time reference assembly for System.Runtime.InteropServices.RuntimeInformation on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with ubuntu.15.10-x64.
    One or more packages are incompatible with .NETCoreApp,Version=v1.0 (ubuntu.15.10-x64).

This is to be expected as rc2 is actually not installed on the machine, and I want to build it on the linux machine

Answer

Download the tar.gz package from https://dotnet.microsoft.com/download/dotnet and install the package with this command:

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

the scound version will be added to sdks folder and you can confirm the installation by running:

dotnet --list-sdks

I have found all the other solutions useless and hard to utilize and dotnet-install script is just very hard to use and pointless.