我這是個新裝的服務器,沒有安裝任何軟件。
一、發布流程
1.安裝AspNetCoreModule托管模塊,同時會自動安裝..net core runtime
DotNetCore.2.0.8-WindowsHosting.exe
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index?view=aspnetcore-2.0
2.重啟電腦,或者使用如下命令重啟IIS
net stop was /y net start w3svc
3.安裝IIS
4.將項目發布到IIS
5.編輯應用程序池,把.net clr版本設置為無托管代碼
二、遇到問題
1.瀏覽器運行項目,報錯如下:
HTTP Error 502.5 - Process Failure
Common causes of this issue:
• The application process failed to start
• The application process started but then stopped
• The application process started but failed to listen on the configured port
Troubleshooting steps:
• Check the system event log for error messages
• Enable logging the application process' stdout messages
• Attach a debugger to the application process and inspect
這個錯誤網上有各種各樣的解決方案,但是苦苦嘗試了將近一天的時間沒有一個適合我的。現在匯總各種解決方案,可能有適合你的:
https://www.cnblogs.com/iiwen/p/9209391.html
https://blog.csdn.net/CuiLanren/article/details/80777488
2.查看windows錯誤日志信息如下:
Application 'MACHINE/WEBROOT/APPHOST/FORM' with physical root 'C:\fabu\' failed to start process with commandline 'dotnet .\Cloud.Boss.dll', ErrorCode = '0x80004005 : c0000135.
3.使用dotnet.exe命令dotnet d:\fabu\boss.dll運行項目,報錯如下:
---------------------------
dotnet.exe - 系統錯誤
---------------------------
無法啟動此程序,因為計算機中丟失 api-ms-win-crt-runtime-l1-1-0.dll。嘗試重新安裝該程序以解決此問題。
---------------------------
確定
---------------------------
3.1. 解決3的錯誤的方案是:
安裝Visual C++ Redistributable for Visual Studio 2015 組件
api-ms-win-crt-runtime組件為 MFC 的運行時環境的庫,是用微軟的visual studio C++編譯的,底層也會用到微軟提供的C++庫和runtime庫,安裝Visual C++ Redistributable for Visual Studio 2015 組件即可解決此問題
下載地址:https://www.microsoft.com/en-us/download/details.aspx?id=48145,
如果安裝時報錯如下:
更新windows系統,或者參考文章:https://blog.csdn.net/neochan1108/article/details/78084073
4.瀏覽器重新輸入項目地址,問題解決。
總結
為什么我以前的服務器沒有遇到這個問題呢,
那是因為我以前的服務器都裝了sqlserver,他會自動安裝Visual C++ Redistributable for Visual Studio 2015 組件。而我這個項目用的是mysql,就沒有安裝此組件。
其實微軟官網文檔已經說明了,只是我沒有看,如下:
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index?view=aspnetcore-2.0