C# 如何通过VSTS关闭system.web编译调试模式
我将此web.config文件的编译选项设置如下:C# 如何通过VSTS关闭system.web编译调试模式,c#,asp.net,azure-web-app-service,azure-pipelines,C#,Asp.net,Azure Web App Service,Azure Pipelines,我将此web.config文件的编译选项设置如下: <configuration> ... <system.web> <compilation debug="true" targetFramework="4.5" /> </system.web> </configuration> ... 如何通过VSTS的构建定义将编译的调试标志关闭为false 更新: 我正在通过VSTS的发布功能将系统部署到Azure服务器。
<configuration>
...
<system.web>
<compilation debug="true" targetFramework="4.5" />
</system.web>
</configuration>
...
如何通过VSTS的构建定义将编译的调试标志关闭为false
更新:
我正在通过VSTS的发布功能将系统部署到Azure服务器。您可以使用转换来实现您想要的。 以下是文件: 下面是Web.debug.config文件的外观。如果要在发布模式下使用transform,也可以使用web.release.config
<?xml version="1.0"?>
<!-- For more information on using Web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=301874 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an atrribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation debug="false" xdt:Transform="Replace"/>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your Web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
您可以使用转换来实现您想要的。 以下是文件: 下面是Web.debug.config文件的外观。如果要在发布模式下使用transform,也可以使用web.release.config
<?xml version="1.0"?>
<!-- For more information on using Web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=301874 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an atrribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation debug="false" xdt:Transform="Replace"/>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your Web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
为什么不使用转换?Web.config具有转换功能,可用于更改值。到上面@Justcode的注释。为什么不使用转换?Web.config具有转换功能,可用于更改值。以上@Justcode的评论。你也可以参考此链接:@joycai谢谢。你也可以参考此链接:@joycai谢谢。