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

Matthias Hermsen 1 Reputation point
2022-05-14T14:03:28.873+00:00

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 ?

Developer technologies | .NET | .NET Runtime
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 78,086 Reputation points Volunteer Moderator
    2022-05-14T18:08:44.907+00:00

    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.


  2. Bruce (SqlWork.com) 78,086 Reputation points Volunteer Moderator
    2022-05-14T21:23:08.343+00:00

    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


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.