文章出處
文章列表
今天第一次將整個 asp.net core 站點發布到 IIS 上,以前都是發布到 Linux 服務器上。
開始使用 dotnet publish -c release 命令發布,用瀏覽器訪問站點時出現下面的錯誤:
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
而在命令行下通過發布時生成的可執行文件運行站點正常(Web服務器用的是Kestrel)。
打開 web.config 文件一看發現 processPath 的值不對:
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
這個值應該是在發布時被替換的,怎么沒替換呢?
到 project.json 中一看,發現下面的東東:
"scripts": { "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] }
目測 web.config 的轉換工作是 dotnet publish-iis 命令的任務之一。
于是手動運行 dotnet publish-iis 命令:
dotnet publish-iis -p "bin\release\netcoreapp1.1\win8-x64\publish" -f win8-x64
出現下面的錯誤提示(實際上在使用 dotnet publish 命令時已經出現這個錯誤提示,由于提示文字沒有以不同顏色區分顯示,所以當時沒注意):
The specified framework 'Microsoft.NETCore.App', version '1.1.0-preview1-001100-00' was not found. - Check application dependencies and target a framework version installed at: C:\Program Files\dotnet\shared\Microsoft.NETCore.App - The following versions are installed: 1.1.0 - Alternatively, install the framework version '1.1.0-preview1-001100-00'
project.json 中 Microsoft.NETCore.App 的版本都已經是 1.1.0 ,怎么還報找不到 1.1.0-preview1 的錯誤?
在 project.json 中巡視一番,遂懷疑下面的 NuGet 包還在依賴 Microsoft.NETCore.App 1.1.0-preview1。
"tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": { "version": "1.0.0-*", "imports": "portable-net45+win8+dnxcore50" } }
將之升級為最新版 1.1.0-preview4-final ,問題解決。
dotnet publish-iis 命令成功執行:
$ dotnet publish-iis -p "bin\release\netcoreapp1.1\win8-x64\publish" -f win8-x64 Configuring the following project for use with IIS: 'bin\release\netcoreapp1.1\win8-x64\publish' Updating web.config at 'bin\release\netcoreapp1.1\win8-x64\publish\web.config' Configuring project completed successfully
dotnet publish -c release 命令也生成了轉換后的 web.config 。
<aspNetCore processPath=".\CNBlogs.XXX.WebApi.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
文章列表
全站熱搜