0
我使用Visual Studio 2015的「發佈」功能部署Web App。我想改變它,以便出版後,在web.config文件中包含下面的代碼片段:Web.config Asp.net 5使用Visual Studio發佈後的更改
<environmentVariables>
<environmentVariable name="Hosting:Environment" value="Staging" />
</environmentVariables>
我試過直接將上面的代碼在VS的項目,像這樣的web.config文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform
processPath="%DNX_PATH%"
arguments="%DNX_ARGS%"
stdoutLogEnabled="true"
stdoutLogFile="..\logs\stdout"
startupTimeLimit="3600"
forwardWindowsAuthToken="true">
<environmentVariables>
<environmentVariable name="Hosting:Environment" value="Staging" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
然而,發佈命令的輸出仍然產生web.config文件中沒有我的加法:
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform
processPath="..\approot\web.cmd"
arguments=""
stdoutLogEnabled="true"
stdoutLogFile="..\logs\stdout"
startupTimeLimit="3600"
forwardWindowsAuthToken="true">
</httpPlatform>
</system.webServer>
</configuration>
我缺少的東西?爲了使web.config文件的發佈版本能夠反映這些更改,還有其他事情需要我做嗎?
是否使用在發佈的任何時間配置的轉型?你的項目中是否有Web.Debug.config和Web.Release.config? – TejSoft
我最後的信息是,你不能通過VS2015發佈到IIS,只有Azure。對於IIS,您需要使用'dnu build'來構建它,手動將其複製到所需的文件夾並手動設置iis中的Web應用程序,該應用程序指向應用程序wwwroot文件夾 – Tseng
@TejSoft不需要一個web.config文件 – painiyff