C# Web.config Asp.net 5在使用Visual Studio发布后发生更改
我正在使用Visual Studio 2015的“发布”功能部署Web应用程序。我想更改它,以便在发布后,web.config文件包含以下代码段:C# Web.config Asp.net 5在使用Visual Studio发布后发生更改,c#,configuration,visual-studio-2015,web-config,asp.net-core,C#,Configuration,Visual Studio 2015,Web Config,Asp.net Core,我正在使用Visual Studio 2015的“发布”功能部署Web应用程序。我想更改它,以便在发布后,web.config文件包含以下代码段: <environmentVariables> <environmentVariable name="Hosting:Environment" value="Staging" /> </environmentVariables> 我尝试将上述代码段直接添加到VS项目的web.config文件中,
<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>
但是,Publish命令的输出仍然会生成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文件的发布版本反映这些更改,我还需要做些什么吗?您可以使用Gulp在发布时向web.config(或任何其他相关文件)添加任何代码片段:
发布时您是否使用任何配置转换?您的项目中有任何Web.Debug.config和Web.Release.config吗?我最后的信息是,您还不能通过VS2015发布到IIS,只有Azure。对于IIS,您需要使用
dnu build
来构建它,手动将其复制到所需文件夹,并在IIS中手动设置指向应用程序wwwroot的web应用程序folder@TejSoft没有,只有一个web.configfile@Tseng您可以通过VS2015发布。看见