如何将以前的 dotnet 版本与最新版本一起安装?

如何将以前的 dotnet 版本与最新版本一起安装?

我正在使用 PopOs 21.10 并使用最新的 dotnet 版本

在此输入图像描述

现在我必须安装以前的版本点网核心 3.1

我试过

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

 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

但出现错误

E: 无法找到包 dotnet-sdk-3.1

E:无法通过 glob 'dotnet-sdk-3.1' 找到任何包

我也尝试过更改包名

 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

但出现类似的错误。下载 tar 存档时,我从下载目录中运行这些命令

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

但即使重新启动后,我在我的机器上也找不到任何 3.1 版本。有人介意帮助如何安装以前的版本而不删除其他版本吗?

答案1

您应该packages-microsoft-prod.deb先安装该文件。

wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt update
sudo apt install dotnet-sdk-3.1

这是输出apt policy dotnet-sdk-3.1

Installed: (none)
  Candidate: 3.1.419-1
  Version table:
     3.1.419-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.418-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.417-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.416-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.415-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.414-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.413-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.412-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.411-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.410-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.409-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.408-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.120-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.119-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.118-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.117-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.116-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.115-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages
     3.1.114-1 500
        500 https://packages.microsoft.com/ubuntu/21.04/prod hirsute/main amd64 Packages

安装指南:在 Ubuntu 上安装 .NET SDK 或 .NET 运行时

手动添加 Microsoft 存储库:
echo "deb [arch=amd64,arm64,armhf] https://packages.microsoft.com/ubuntu/21.04/prod hirsute main" |
sudo tee /etc/apt/sources.list.d/microsoft-prod.list
sudo apt update
sudo apt install dotnet-sdk-3.1

相关内容