美文网首页
在VSCode写.netCore 踩坑记五(linux部署)

在VSCode写.netCore 踩坑记五(linux部署)

作者: 有头发的搬砖员 | 来源:发表于2021-03-25 10:00 被阅读0次

写了几天的代码,终于到部署的时候了,那么该怎么部署到linux上呢?

部署系统:CentOS7
.net core 版本 :2.0

安装前,先运行以下命令,将 Microsoft 包签名密钥添加到受信任密钥列表,并添加 Microsoft 包存储库:

sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm

1、安装 dotnet-sdk
不管是开发,还是运行,都需要安装 dotnet-sdk

sudo yum update 

如果是开发的需要安装

sudo yum install dotnet-sdk-2.0.0 //根据自己的版本需求

如果不需要开发,只需要运行可以只安装

sudo yum install dotnet-runtime-2.0.0 //根据自己的版本需求

2、把发布好的项目拷贝过来执行

dotnet xxx.dll

3、可能出现的问题

如出现错误1:

Error:
An assembly specified in the application dependencies manifest (WebApplication
1.deps.json) was not found:
package: ‘BouncyCastle.NetCore’, version: ‘1.8.3’
path: ‘lib/netstandard2.0/BouncyCastle.Crypto.dll’

是因为在发布时未能完全还原引用的nuget包造成
请使用dotnet publish 命令发布应用


如出现错误2:

Failed to load /opt/dotnet/shared/Microsoft.NETCore.App/1.1.0/libcoreclr.so, error: libunwind.so.8: cannot open shared object file: No such file or directory
Failed to bind to CoreCLR at '/opt/dotnet/shared/Microsoft.NETCore.App/1.1.0/libcoreclr.so'

则安装:

yum install libunwind

如出现错误3:

Failed to initialize CoreCLR, HRESULT: 0x80131500

则安装:

yum install icu

如出现错误4:

Error:
  An assembly specified in the application dependencies manifest (xxx.deps.json) was not found:
    package: 'Microsoft.AspNetCore.Antiforgery', version: '2.0.1'
    path: 'lib/netstandard2.0/Microsoft.AspNetCore.Antiforgery.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.3.xml

出现了这个错误,原因是未安装dotnet-hosting-2.0.x(你软件对应的.net core 版本)

yum install dotnet-hosting-2.0.X

相关文章

网友评论

      本文标题:在VSCode写.netCore 踩坑记五(linux部署)

      本文链接:https://www.haomeiwen.com/subject/zmrlhltx.html