当前位置: 首页>>技术教程>>正文


Ubuntu-安装.net核心

, , ,

问题描述

我想尝试新的.net核心。我正在按照https://www.microsoft.com/net/core的说明进行操作,但无法正常工作。

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-dev-1.0.0-preview1-002702 : Depends: dotnet-sharedframework-microsoft.netcore.app-1.0.0-rc2-3002702 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

我正在运行Ubuntu 16.04。

最佳解决办法

UPDATED see at the end. (thanks to Prasanna)

.NET core now supports Ubuntu 14.04, 16.04, 16.10 & Linux Mint 17.

Please check the official page for all the details.

今天(2016年5月)仅支持Ubuntu 14.04。

我通过添加在Ubuntu 15.10上成功安装了它

deb http://security.ubuntu.com/ubuntu trusty-security main

到/etc /apt /sources-list

完成后,您应该执行以下操作:

apt-get update

apt-get upgrade

并再次命令

apt-get install dotnet-dev-1.0.0-preview1-002702a

它将要求安装额外的软件包;您回答是,您就完成了!

输入测试

dotnet --version

请享用!

更新

次佳解决办法

现在,.NET Core支持ubuntu 16.04。

请检查链接以获取更多详细信息

https://www.microsoft.com/net/core#linuxubuntu

You need to setup the apt-feed first for ubuntu 16.04.

Remove previous .net core versions from your system if any

Then install .net core sdk

第三种解决办法

2018年9月-在Ubuntu上.NET Core的安装非常简单:

注册Microsoft密钥,产品存储库,并安装所需的依赖项:

重要说明:将以下路径中的18.04更改为您的Ubuntu版本(即:17.10、16.04等)

wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb

现在更新可用软件包列表并安装您的SDK

sudo apt-get update
sudo apt-get install dotnet-sdk-2.1

做完了!

附加信息:

对我而言(2018年9月结束)是2.1版,但您可以检查以下最新版本:

sudo apt-cache search dotnet-sdk

还请注意:Microsoft在其官方页面(here)建议在安装dotnet-sdk-your_version之前,先使用sudo apt-get安装apt-transport-https。不再需要,因为(从软件包描述中):

Description-en: transitional package for https support This is a dummy transitional package – https support has been moved into the apt package in 1.5. It can be safely removed.

因此,请随时跳过此步骤。

第四种办法

我在同一条船上。我想尝试一下,而不会遇到所有安装麻烦。我走了docker路线,发现它起来起来起来更简单。另外,尝试后它更容易清理,因为我要做的就是删除容器+映像。

我走这条路的另一个原因是因为我使用的Ubuntu 15.10与Ubuntu的.Net Core安装没有正式兼容。因此,与其将我的发行版升级到”try”,不如使用docker更好。

我在交互式 shell 中运行它,以便可以运行我的代码:

docker run -it --name dotnet -v /home/me/tmp/:/tmp/project microsoft/dotnet /bin/bash

..然后在我的/home /me /tmp目录中使用文本编辑器编写一些示例代码,当我想运行它时,我只是转到容器 shell 并执行dotnet run

看到:

https://github.com/dotnet/dotnet-docker

https://www.microsoft.com/net/core#dockercmd

第五种办法

尝试安装从属软件包dotnet-sharedframework-microsoft.netcore.app将获得下一个错误,说此软件包取决于libicu52,但无法安装

http://packages.ubuntu.com/pl/trusty/amd64/libicu52/download

并下载.deb软件包。现在,转到下载位置并通过运行以下命令安装软件包:

sudo dpkg -i libicu52_52.1-3ubuntu0.4_amd64.deb

现在,您将能够运行以下命令:

sudo apt-get install dotnet-sharedframework-microsoft.netcore.app-1.0.0-rc2-3002702
sudo apt-get install dotnet-dev-1.0.0-preview1-002702

dotnet --version

祝好运

资料来源:http://zablo.net/blog/post/run-and-debug-asp-net-core-rc2-ubuntu-16-04

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/7480.html,未经允许,请勿转载。