.Net Core Runtime安装说明

在开发阶段,都是直接安装.Net Core的SDK,可是在部署的时候你仍是直接装SDK吗?固然直接装SDK也没什么问题,也能够少一些麻烦。可是若是你像我同样不喜欢在产线上装SDK,只想装Runtime,那么这篇文章可能会对你有帮助。这里咱们谈的都是针对便携式发布的应用程序。html

.Net 下载中心

https://www.microsoft.com/net...linux

你能够在这里下载全部.Net相关的运行时或者SDK。这里咱们主要看看.Net Core。json

.Net Core应用程序

如使用便携式发布的,那发布的程序中不会包含.Net Core运行时,在部署到服务器的时候就须要安装对应的.Net Core运行时。可直接按照官方的文档,使用包管理器来安装。ubuntu

例如:Linux Ubuntu 16.04服务器

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-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-runtime-2.0.6

这样你的程序就能够正常运行了。app

ASP.Net Core应用程序

若是你的是ASP.Net Core应用程序,你会发现使用上述方式安装了.net core运行时以后,你的程序仍是没法正常运行。会出现大概相似下面这样的错误:curl

Error:
 An assembly specified in the application dependencies manifest (ZKEACMS.WebHost.deps.json) was not found:
 package: 'Microsoft.ApplicationInsights.AspNetCore', version: '2.1.1'
 path: 'lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll'
 This assembly was expected to be in the local runtime store as the application was published using the following target manifest files:
 aspnetcore-store-2.0.0-linux-x64.xml;aspnetcore-store-2.0.0-osx-x64.xml;aspnetcore-store-2.0.0-win7-x64.xml;aspnetcore-store-2.0.0-win7-x86.xml

这是由于只安装了.Net Core运行时,而没有安装ASP.NET Core运行时。工具

固然,你也能够在发布的时候带上它:post

<PropertyGroup>
 <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest> 
</PropertyGroup>

或者直接在运行时里面补上它就能够了。下载它,而后解压到dotnet的安装目录url

083dc2a7090d4d10a686d6c3a499c2e3.png

wget -O aspnetcore-store.tar.gz https://download.microsoft.com/download/8/D/A/8DA04DA7-565B-4372-BBCE-D44C7809A467/aspnetcore-store-2.0.6-linux-x64.tar.gz
tar zxf aspnetcore-store.tar.gz -C /usr/share/dotnet

而后你就能够运行你的程序了。

Server Hosting

微软已经为你打包好了.Net Core Runtime和ASP.Net Core Runtime,能够不用先装.Net Core Runtime再装ASP.Net Core Runtime,直接下载就可使用了:

a9cf25a8cde3456c8e106bd3a7e22319.png

mkdir dotnet
wget -O https://download.microsoft.com/download/8/D/A/8DA04DA7-565B-4372-BBCE-D44C7809A467/dotnet-hosting-2.0.6-linux-x64.tar.gz
tar zxf aspnetcore-store.tar.gz -C dotnet

Windows比较简单,直接安装[]()Windows Server Hosting就能够了。

不过,为何不能够经过包管理工具,直接安装.Net Core Runtime和ASP.Net Core Runtime呢?

原文连接:http://www.zkea.net/codesnipp...

相关文章
相关标签/搜索