寫了幾天的代碼,終于到部署的時(shí)候了羊赵,那么該怎么部署到linux上呢?
部署系統(tǒng):CentOS7
.net core 版本 :2.0
安裝前扇谣,先運(yùn)行以下命令昧捷,將 Microsoft 包簽名密鑰添加到受信任密鑰列表,并添加 Microsoft 包存儲庫:
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
1罐寨、安裝 dotnet-sdk
不管是開發(fā)靡挥,還是運(yùn)行,都需要安裝 dotnet-sdk
sudo yum update
如果是開發(fā)的需要安裝
sudo yum install dotnet-sdk-2.0.0 //根據(jù)自己的版本需求
如果不需要開發(fā)鸯绿,只需要運(yùn)行可以只安裝
sudo yum install dotnet-runtime-2.0.0 //根據(jù)自己的版本需求
2跋破、把發(fā)布好的項(xiàng)目拷貝過來執(zhí)行
dotnet xxx.dll
3、可能出現(xiàn)的問題
如出現(xiàn)錯(cuò)誤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’
是因?yàn)樵诎l(fā)布時(shí)未能完全還原引用的nuget包造成
請使用dotnet publish 命令發(fā)布應(yīng)用
如出現(xiàn)錯(cuò)誤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
如出現(xiàn)錯(cuò)誤3:
Failed to initialize CoreCLR, HRESULT: 0x80131500
則安裝:
yum install icu
如出現(xiàn)錯(cuò)誤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
出現(xiàn)了這個(gè)錯(cuò)誤瓶蝴,原因是未安裝dotnet-hosting-2.0.x(你軟件對應(yīng)的.net core 版本)
yum install dotnet-hosting-2.0.X