ubnutu下安装.NetCore出现的问题解决

我在ubnutu on win10 subsystem下安装.NetCore,做一个尝鲜。但是在安装的过程中却出现了问题,不能安装成功。我记录下我的完整安装过程,并说明解决办法。其实非常简单。

ubnutu版本 14.04

sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
sudo apt-get update

官网对应安装文档链接

sudo apt-get install  dotnet-dev-1.0.0-preview2.1-003177

安装过程中出现了如下问题:

Preparing to unpack .../dotnet-host_1.1.0-preview1-001100-00-1_amd64.deb ...
Unpacking dotnet-host (1.1.0-preview1-001100-00-1) ...
dpkg: error processing archive /var/cache/apt/archives/dotnet-host_1.1.0-preview1-001100-00-1_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/dotnet', which is also in package dotnet-dev 1.0.0.1451415522-1
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Errors were encountered while processing:
 /var/cache/apt/archives/dotnet-host_1.1.0-preview1-001100-00-1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

当时没看明白这个问题。根据提示使用命令

sudo apt-get install -f

修复也没用,仍有错误。

root@XU-PC:/var/cache/apt/archives# dpkg --configure -a
dpkg: dependency problems prevent configuration of dotnet-hostfxr-1.1.0:
 dotnet-hostfxr-1.1.0 depends on dotnet-host (>= 1.1.0); however:
  Package dotnet-host is not installed.

后来看到一篇类似问题的帖子。

将dotnet-dev先卸载再修复。就OK。

root@XU-PC:/var/cache/apt/archives# dpkg -r dotnet-dev
(Reading database ... 118320 files and directories currently installed.)
Removing dotnet-dev (1.0.0.1451415522-1) ...


root@XU-PC:/var/cache/apt/archives# sudo apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  liblldb-3.6 libllvm3.6
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  dotnet-host
The following NEW packages will be installed:
  dotnet-host
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
3 not fully installed or removed.
Need to get 0 B/34.5 kB of archives.
After this operation, 155 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline
Selecting previously unselected package dotnet-host.
(Reading database ... 117860 files and directories currently installed.)
Preparing to unpack .../dotnet-host_1.1.0-preview1-001100-00-1_amd64.deb ...
Unpacking dotnet-host (1.1.0-preview1-001100-00-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up dotnet-host (1.1.0-preview1-001100-00-1) ...
Setting up dotnet-hostfxr-1.1.0 (1.1.0-1) ...
Setting up dotnet-sharedframework-microsoft.netcore.app-1.1.0 (1.1.0-1) ...
Setting up dotnet-dev-1.0.0-preview2-1-003177 (1.0.0-preview2-1-003177-1) ...
This software may collect information about you and your use of the software, and send that to Microsoft.
Please visit http://aka.ms/dotnet-cli-eula for more information.


root@XU-PC:/var/cache/apt/archives# dotnet --version
1.0.0-preview2-1-003177

由此.NetCore在ubnutu on win10 subsystem上安装成功。 我怀疑是不是之前安装了其他版本导致的问题。

安装完毕后创建工程并运行,结果如下:

root@XU-PC:/mnt/d/testjson# mkdir dotnettest

root@XU-PC:/mnt/d/testjson# cd dotnettest/
root@XU-PC:/mnt/d/testjson/dotnettest# dotnet new
Created new C# project in /mnt/d/testjson/dotnettest.
root@XU-PC:/mnt/d/testjson/dotnettest# ls
Program.cs  project.json

root@XU-PC:/mnt/d/testjson/dotnettest# dotnet restore
log  : Restoring packages for /mnt/d/testjson/dotnettest/project.json...
log  : Writing lock file to disk. Path: /mnt/d/testjson/dotnettest/project.lock.json
log  : /mnt/d/testjson/dotnettest/project.json
log  : Restore completed in 3099ms.

root@XU-PC:/mnt/d/testjson/dotnettest# dotnet run
Project dotnettest (.NETCoreApp,Version=v1.1) will be compiled because expected outputs are missing
Compiling dotnettest for .NETCoreApp,Version=v1.1

Compilation succeeded.
    0 Warning(s)
    0 Error(s)

Time elapsed 00:00:03.1612850

Hello World!

转载于:https://my.oschina.net/myspaceNUAA/blog/813076

你可能感兴趣的:(ubnutu下安装.NetCore出现的问题解决)