42

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

miftahulrespati
  • 494
  • 4
  • 16
nicolaas
  • 1,783
  • 1
  • 17
  • 24
  • 2
    Did you try [standalone deployment](https://learn.microsoft.com/en-us/dotnet/articles/core/deploying/index#portable-applications) option for .Net core? –  Aug 31 '16 at 02:34
  • I haven't. Didn't think of that before... I'll try it out now, thanks! – nicolaas Aug 31 '16 at 06:31
  • did you find solution to your problem? – Sharif Sep 14 '17 at 23:07
  • @Sharif I'm sorry, we didn't. If i remember correctly we found a workaround (basically just spinning up another VM with only the specific version installed) – nicolaas Sep 16 '17 at 07:46
  • yeah, this is pretty much what I'm also doing as a workaround. – Sharif Sep 20 '17 at 13:45
  • Maybe it's a job for Docker? See https://docs.docker.com/engine/examples/dotnetcore/ – unigeek Jan 19 '18 at 17:53

5 Answers5

14

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.

  • 2
    For me this is the easiest solution. No bothering with symlinks etc. – Neits Jul 05 '21 at 15:05
  • did not work for me on Ubuntu 22.04, .Net 6 as main dotnet and .Net 5 as parallel installation. – Afshar Mohebi Jun 21 '22 at 14:34
  • Ubuntu 22, I first got rid of all dotnet traces and then installed 5 and 6. For me, as well, this is the only solution that worked. – Battlefury Sep 09 '22 at 04:35
  • This is the best solution imo. – Arad Alvand Nov 25 '22 at 18:47
  • You also need global.json file in root, so `dotnet run` auto-chooses the correct version. In root use `dotnet new globaljson` to create it. – s3c Dec 08 '22 at 10:27
  • This should be the accepted answer as I have tried every other way and nothing works. I have .net 5,6,7 now installed this way and it is working flawless with Rider 22.3.1. Thanks Mohammad! – Brian Jan 12 '23 at 19:38
11

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

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

Giovanni Bassi
  • 739
  • 6
  • 18
  • another nice wiki post https://wiki.archlinux.org/index.php/.NET_Core – Davi Fiamenghi May 01 '20 at 02:01
  • 1
    on Fedora, I had to install on the same folder as my current SDK... `dotnet --list-sdks` `3.1.201 [/usr/share/dotnet/sdk]`. With the command `./dotnet-install.sh -Version 2.1.805 --install-dir /usr/share/dotnet` – Davi Fiamenghi May 01 '20 at 02:05
  • @DaviFiamenghi Thanks! Worked like a charm on Ubuntu 20.10. – Łukasz Sypniewski Dec 21 '20 at 15:25
  • This script is tailored for CI use cases. Notice the message from the script: Note that the intended use of this script is for Continuous Integration (CI) scenarios, where: The SDK needs to be installed without user interaction and without admin rights. The SDK installation doesn't need to persist across multiple CI runs. – Afshar Mohebi Jun 21 '22 at 15:04
4

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.

Eric Roller
  • 429
  • 5
  • 19
1

I have .Net 6 installed on my Ubuntu 22.04 and needed .Net 5 to be installed side-by-side. After downloading .Net 5 SDK, I uncompressed the downloaded file and tried to put it in the path just like 'Mohammad HS Farvashani. solution.

But the path did not work. I mean calling dotnet -v was showing 6 everywhere. Additionally, dotnet --list-sdks just showed 6.

My work-around was to call the dotnet 5 from its installation directory only. Just like this:

~/dotnet5/dotnet run

It helped me to run a .Net 5 application and it was enough for my purpose.

Consider that before it getting to run I encountered error

No usable version of libssl was found

This error resolved by running:

wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5.9_amd64.deb
sudo dpkg -i libssl1.0.0_1.0.2n-1ubuntu5.9_amd64.deb

from this answer.

Afshar Mohebi
  • 10,479
  • 17
  • 82
  • 126
0

Based on Mohammad's answer (which worked well), here is a more complete example installing dotnet 5 and 3.1 side by side:

env DOTNET_ROOT=/usr/share/dotnet
env PATH=$PATH:usr/share/dotnet
env DOTNET_SDK_VERSION=5.0.401
env DOTNET_SDK_VERSION2=3.1.413
   
curl -SL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \
    && dotnet_sha512='a444d44007709ceb68d8f72dec0531e17f85f800efc0007ace4fa66ba27f095066930e6c6defcd2f85cdedea2fec25e163f5da461c1c2b8563e5cd7cb47091e0' \
    && echo "$dotnet_sha512  dotnet.tar.gz" | sha512sum -c - \
    && mkdir -p /usr/share/dotnet \
    && tar -zxf dotnet.tar.gz -C /usr/share/dotnet \
    && rm dotnet.tar.gz \
    #&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
    # Trigger first run experience by running arbitrary cmd
    && dotnet help

curl -SL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/3.1.413/dotnet-sdk-3.1.413-linux-x64.tar.gz \
    && dotnet_sha512='2a0824f11aba0b79d3f9a36af0395649bc9b4137e61b240a48dccb671df0a5b8c2086054f8e495430b7ed6c344bb3f27ac3dfda5967d863718a6dadeca951a83' \
    && echo "$dotnet_sha512  dotnet.tar.gz" | sha512sum -c - \
    #&& mkdir -p /usr/share/dotnet31 \
    && tar -ozxf dotnet.tar.gz -C /usr/share/dotnet \
    && rm dotnet.tar.gz \
    #&& ln -s /usr/share/dotnet31/dotnet /usr/bin/dotnet31 \
    # Trigger first run experience by running arbitrary cmd
    && dotnet help
Christopher Scott
  • 2,676
  • 2
  • 26
  • 26