在 ubuntu 中安装 .net core 2.0 sdk 时出错

在 ubuntu 中安装 .net core 2.0 sdk 时出错

我尝试在 ubuntu 17.04 中安装 .net core 2.0,但出现如下错误

**Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
 dotnet-sdk-2.0.0 : Depends: dotnet-runtime-2.0.0 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.**

正在使用下面的过程来安装它

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-zesty-prod zesty main" > /etc/apt/sources.list.d/dotnetdev.list' 
sudo apt-get update

sudo apt-get install dotnet-sdk-2.0.0

请帮我修复这个问题。

答案1

SDK 版本和链接取决于你的 ubuntu 版本,你必须在列表。但如果你使用 18.04,你必须遵循这些命令

# NO_PUBKEY EB3E94ADBE1229CF
sudo apt-key adv --keyserver packages.microsoft.com --recv-keys EB3E94ADBE1229CF

# NO_PUBKEY B02C46DF417A0893
sudo apt-key adv --keyserver packages.microsoft.com --recv-keys 52E16F86FEE04B979B07E28DB02C46DF417A0893

sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic main" > /etc/apt/sources.list.d/dotnetdev.list'

sudo apt update
sudo apt install dotnet-sdk-2.1.300-preview2-008533

来自 Github 问题

答案2

我遇到了同样的问题,结果发现我没有使用 17.04。我在 Windows 10 上的 WSL 中,它的版本实际上是 14.04。我检查了版本:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:        14.04
Codename:       trusty

所以...正确的安装命令是:

sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main" > /etc/apt/sources.list.d/dotnetdev.list' 
sudo apt-get update
sudo apt-get install dotnet-sdk-2.0.0

MS 文档在这里: https://www.microsoft.com/net/core#linuxubuntu

相关内容