question

MatthiasHermsen-5627 avatar image
0 Votes"
MatthiasHermsen-5627 asked Bruce-SqlWork commented

How to install previous dotnet versions ( 3.1 ) on Linux ( Ubuntu )

I'm using an Ubuntu based distribution and installed version 5.0.404 and 6.0.101 and now have to install the previous version 3.1 ( core ). After running

 wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

I'm trying to figure out which commands to run to install the SDK and runtime. For the SDK I tried several versions e.g.

 sudo apt-get update; \
   sudo apt-get install -y apt-transport-https && \
   sudo apt-get update && \
   sudo apt-get install -y dotnet-sdk-3.1

or

 sudo apt-get update; \
   sudo apt-get install -y apt-transport-https && \
   sudo apt-get update && \
   sudo apt-get install -y aspnetcore-sdk-3.1

but it couldn't locate the package. Does someone know the correct package name for .Net Core 3.1.x ?

dotnet-runtime
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered MatthiasHermsen-5627 commented

I use macOS instead of linux, but:

 #download the latest version of the Microsoft install package
 wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
    
 #install the package
  sudo dpkg -i packages-microsoft-prod.deb
    
 #delete the download
  rm packages-microsoft-prod.deb

apt-get is an alternative package installer to dpkg.

 sudo apt-get update; \
   sudo apt-get install -y apt-transport-https && \
   sudo apt-get update && \
   sudo apt-get install -y dotnet-sdk-6.0

line 1 updates apt-get to the latest version
line 2 install https support for apt-get
line 3 run apt-get update again
line 4 fetch and install dotnet-sdk-6.0

to install the 3.1 sdk you would need to know the package name. if you look at the 3.1 install instructions, they use apt rather than apt-get

sudo apt install dotnet-sdk-3.1

if you don't have apt, just download the tar file and extract t the correct folder.

 DOTNET_FILE=dotnet-sdk-6.0.100-linux-x64.tar.gz
 export DOTNET_ROOT=$(pwd)/.dotnet
    
 mkdir -p "$DOTNET_ROOT" && tar zxf "$DOTNET_FILE" -C "$DOTNET_ROOT"
    
 export PATH=$PATH:$DOTNET_ROOT


use the correct tar file name.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks @Bruce-SqlWork , yes you are right, I used the wrong command description.

Before installing things by hand, I'm running

 wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

after that I tried

 sudo apt update; \
    sudo apt install -y apt-transport-https && \ 
    sudo apt update && \ 
    sudo apt install -y dotnet-sdk-3.1

but still get the error

E: Unable to locate package dotnet-sdk-3.1
E: Couldn't find any package by glob 'dotnet-sdk-3.1'

Did I miss something?

0 Votes 0 ·
Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered Bruce-SqlWork commented

you probably have to use an earlier package source

 wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb 

but as you have already installed net 6, I'd do a manual install from the download tar

https://dotnet.microsoft.com/en-us/download/dotnet/3.1



· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I tried the manual installer and downloaded the binaries. From inside the downloads directory I run

 mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-3.1.419-linux-arm64.tar.gz -C $HOME/dotnet
 export DOTNET_ROOT=$HOME/dotnet
 export PATH=$PATH:$HOME/dotnet

but even after restarting the machine I can only find v5 and v6. What am I missing?

0 Votes 0 ·
Bruce-SqlWork avatar image Bruce-SqlWork MatthiasHermsen-5627 ·

did you put them in the correct folder?

dotnet --list-runtimes
dotnet --list-sdks

to see locations. and what is installed

0 Votes 0 ·

dotnet --list-runtimes

outputs

 Microsoft.AspNetCore.App 5.0.13 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
 Microsoft.AspNetCore.App 6.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
 Microsoft.NETCore.App 5.0.13 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
 Microsoft.NETCore.App 6.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

dotnet --list-sdks

outputs

 5.0.404 [/usr/share/dotnet/sdk]
 6.0.101 [/usr/share/dotnet/sdk]

You asked

did you put them in the correct folder?

After downloading the file, where should I put it? I ran the commands from the downloads directory



0 Votes 0 ·
Show more comments