【问题标题】:How to remove a environment variables using config transformations如何使用配置转换删除环境变量
【发布时间】:2020-01-08 19:21:55
【问题描述】:

我有 web.config 以及需要删除的这两个环境变量,请参见下面的 web.config ..

web.config
      <aspNetCore processPath=".\Widgets.API.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess">
        <environmentVariables>
          <environmentVariable name="COMPLUS_ForceENC" value="1" />
          <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
          <environmentVariable name="CORECLR_ENABLE_PROFILING" value="1" />

我正在尝试使用

删除这些变量
web.Release.config

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <location>
    <system.webServer>
      <aspNetCore>
        <!--remove the environment vars section in Release mode-->
        <!--
        Why? Because .NET Core has a bug where it adds environmentVariables section
        during the build with the environment set as Development..  
        This obviously fails in production, which is why we remove it during 
        release.
      -->
        <environmentVariable name="COMPLUS_ForceENC" value="1"  xdt:Transform="Remove" />
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" xdt:Transform="Remove" />
      </aspNetCore>
    </system.webServer>
  </location>
</configuration>

无法使用模式“web.Release.config”转换文件“D:\Octopus\Applications\Widgets\XW QA\WidgetsAPI\2019.9.5_2\web.config”。

【问题讨论】:

标签: .net xml visual-studio web-config web.config-transform


【解决方案1】:

使用下面我能够解决问题。

        <environmentVariables>
          <environmentVariable name="COMPLUS_ForceENC" value="1" xdt:Transform="Remove" xdt:Locator="Match(name)"/>
          <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" xdt:Transform="Remove" xdt:Locator="Match(name)"/>
        </environmentVariables>

【讨论】:

  • 这很好用,尽管由于某种原因我收到以下警告:警告:源文档中没有元素匹配'/configuration/system.webServer/aspNetCore/environmentVariables/environmentVariable[@name='COMPLUS_ForceENC' ]'
猜你喜欢
  • 1970-01-01
  • 2013-10-25
  • 2012-01-11
  • 1970-01-01
  • 2022-11-28
  • 1970-01-01
  • 2022-06-11
  • 2010-12-01
  • 2013-11-13
相关资源
最近更新 更多