Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 443
nicolaas Avatar asked Aug 30 '16 17:08

nicolaas


People also ask

Can I have multiple .NET Core versions installed?

The answer is yes you can.

How do I install multiple versions of Ubuntu?

You should simply create a separate boot partition ;-). Then, when you install a new version of Ubuntu, at the partitioning stage, select to use this new common boot partition for /boot. Do this for all versions of Ubuntu that you install, and you should be able to boot into all of them.

Can I install both .NET Core and .NET framework?

NET Core installations are completely independent from the version of . NET Framework. In fact, you can actually install multiple version of . NET Core side-by-side on the same machine (unlike .


2 Answers

Simply use the dotnet install script: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script

This is a good tutorial: https://www.hanselman.com/blog/SideBySideUserScopedNETCoreInstallationsOnLinuxWithDotnetinstallsh.aspx

like image 163
Giovanni Bassi Avatar answered Sep 21 '22 07:09

Giovanni Bassi


This has been working for us.

  1. Installing multiple versions of dotnet runtime to separate directories.

  2. For the latest runtime installation, add symlinks for each of the older runtimes. For example, for older runtime 1.1.2 we create the symlink /path/to/dotnet-latest/shared/Microsoft.NETCore.App/1.1.2 --> /path/to/dotnet-1.1.2/shared/Microsoft.NETCore.App/1.1.2

  3. Run dotnet from the latest runtime installation and it should pick up the appropriate runtime.

Note that this is equivalent to what happens with the Windows installer. The new runtime is added to the shared installation. A similar approach can be used to get support for multiple sdks from a single installation by adding the appropriate symlinks in the sdk subdirectory.

like image 40
Eric Roller Avatar answered Sep 23 '22 07:09

Eric Roller