我在ubnutu on win10 subsystem下安裝.NetCore,作一個嚐鮮。可是在安裝的過程當中卻出現了問題,不能安裝成功。我記錄下個人完整安裝過程,並說明解決辦法。其實很是簡單。linux
ubnutu版本 14.04json
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
官網對應安裝文檔連接ubuntu
sudo apt-get install dotnet-dev-1.0.0-preview2.1-003177
安裝過程當中出現了以下問題:app
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)
當時沒看明白這個問題。根據提示使用命令frontend
sudo apt-get install -f
修復也沒用,仍有錯誤。ide
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.
後來看到一篇相似問題的帖子。ui
將dotnet-dev先卸載再修復。就OK。this
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上安裝成功。 我懷疑是否是以前安裝了其餘版本致使的問題。spa
安裝完畢後建立工程並運行,結果以下:.net
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!