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