运行时 .NET Core 3.1 和 6.0 是否可以在 Ubuntu 系统(例如 Ubuntu 22.04)上共存?
让我解释一下,我有一台计算机,我需要两个运行时,但我要么安装一个,要么安装另一个。我似乎无法让他们一起工作。 3.1版本的安装是这样完成的:
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb
sudo dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
apt update
apt install apt-transport-https dotnet-runtime-3.1 -y
对于 6.0 版本,我使用以下步骤:
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update
sudo apt install aspnetcore-runtime-6.0
但是,当我运行时dotnet --list-runtimes
,我只看到版本 3.1。如果我只安装6.0,则只显示该版本。但绝不会两者兼而有之。
答案1
我终于设法使它们与以下几行共存:
apt remove --purge dotnet* aspnet* netstandard* -y
wget https://download.visualstudio.microsoft.com/download/pr/39c3ef4c-73c7-4248-8c54-0865d5feb8b2/3420b1ff6b0f36e63044d6f7a794b579/aspnetcore-runtime-3.1.32-linux-x64.tar.gz
wget https://download.visualstudio.microsoft.com/download/pr/fea239ad-fd47-4764-aa71-6a147a82f632/20ee58b0bf08ae9f6e76e37ba3765c57/dotnet-runtime-3.1.32-linux-x64.tar.gz
wget https://download.visualstudio.microsoft.com/download/pr/56d44b17-03c2-4d9e-bdbc-a598ca34fc01/8fcc1e19dfd3c86b09beb68460db6e85/aspnetcore-runtime-6.0.21-linux-x64.tar.gz
wget https://download.visualstudio.microsoft.com/download/pr/25fc0412-b2ff-4868-9920-c087b8a75c55/a95292a725fc37c909c4432c74ecdb43/dotnet-runtime-6.0.21-linux-x64.tar.gz
mkdir /opt/dotnet
tar zxf aspnetcore-runtime-6.0.21-linux-x64.tar.gz -C /opt/dotnet/
tar zxf aspnetcore-runtime-3.1.32-linux-x64.tar.gz -C /opt/dotnet/
tar zxf dotnet-runtime-3.1.32-linux-x64.tar.gz -C /opt/dotnet/
tar zxf dotnet-runtime-6.0.21-linux-x64.tar.gz -C /opt/dotnet/
mkdir /usr/share/dotnet
ln -s /opt/dotnet/dotnet /usr/share/dotnet/dotnet
ln -s /opt/dotnet/dotnet /usr/bin/dotnet
dotnet --list-runtimes