【问题标题】:How to set system.web compilation debug mode off via VSTS如何通过 VSTS 关闭 system.web 编译调试模式
【发布时间】:2018-01-24 04:04:58
【问题描述】:

我有这个 web.config 文件,其编译选项设置如下:

<configuration>
...
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
  </system.web>
</configuration>

如何通过 VSTS 的 Build Definitions 关闭编译的调试标志为 false?


更新: 我正在通过VSTS的发布功能将系统部署到Azure服务器。

【问题讨论】:

  • 为什么不使用转换? Web.config 具有可用于更改值的转换功能。
  • Here's the reference@Justcode 上面的评论。

标签: c# asp.net azure-web-app-service azure-pipelines


【解决方案1】:

您可以使用转换来实现您想要的。 这是文档: https://docs.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/web-config-transformations

这是您的 Web.debug.config 文件的外观。如果要在发布模式下使用转换,也可以使用 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>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2020-06-28
  • 1970-01-01
  • 1970-01-01
  • 2016-08-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-09
相关资源
最近更新 更多