(转载).Net Core Runtime安装说明

原文地址:http://www.zkea.net/codesnippet/detail/post-98.html


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

.Net 下载中心

https://www.microsoft.com/net/download/all

你可以在这里下载所有.Net相关的运行时或者SDK。这里我们主要看看.Net Core。

.Net Core应用程序

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

例如: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

这样你的程序就可以正常运行了。

ASP.Net Core应用程序

如果你的是ASP.Net Core应用程序,你会发现使用上述方式安装了.net core运行时之后,你的程序还是无法正常运行。会出现大概类似下面这样的错误:

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运行时

当然,你也可以在发布的时候带上它(用文本编辑器编辑web项目工程文件 xxx.csproj文件,):

<Project>
...... <PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
</Project>

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

asp.net core runtime.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,直接下载就可以使用了:

server hosting binaries.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呢?

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值