將asp.net core網站發布到IIS上遇到的問題

來源:互聯網
上載者:User

標籤:path   eve   發布   stp   ogr   logging   換工作   server   etc   

今天第一次將整個 asp.net core 網站發布到 IIS 上,以前都是發布到 Linux 伺服器上。

開始使用 dotnet publish -c release 命令發布,用瀏覽器訪問網站時出現下面的錯誤:

HTTP Error 502.5 - Process FailureCommon causes of this issue:The application process failed to startThe application process started but then stoppedThe application process started but failed to listen on the configured portTroubleshooting steps:Check the system event log for error messagesEnable logging the application process’ stdout messagesAttach 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-x64Configuring 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" />

將asp.net core網站發布到IIS上遇到的問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.