Web.config 变换部分应用

Web.config transform applies partially

在我的 web.Release.config 中,我定义了三个转换:

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
  </system.web>
  <system.webServer>
    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" xdt:Transform="SetAttributes" xdt:Locator="Match(directory)">
      <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" xdt:Transform="SetAttributes" xdt:Locator="Match(dll)" />
    </httpCompression>
  </system.webServer>
</configuration>

预览转换应用/发布都显示只有编译标签正在转换。

不明白为什么 httpCompression / scheme 标签保持不变?

以下是原web.config内容的节选:

<httpCompression directory="%TEMP%\iisexpress\IIS Temporary Compressed Files">
  <scheme name="gzip" dll="%IIS_BIN%\gzip.dll" />
  <staticTypes>
    <add mimeType="text/*" enabled="true" />
    <add mimeType="message/*" enabled="true" />
    <add mimeType="image/svg+xml" enabled="true" />
    <add mimeType="application/javascript" enabled="true" />
    <add mimeType="text/javascript" enabled="true" />
    <add mimeType="application/javascript; charset=utf-8" enabled="true" />
    <add mimeType="application/atom+xml" enabled="true" />
    <add mimeType="application/xaml+xml" enabled="true" />
    <add mimeType="*/*" enabled="false" />
  </staticTypes>
</httpCompression>

@lexeme 你的代码不正确。请尝试以下代码:

 <system.webServer>
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" xdt:Transform="SetAttributes">
  <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
</httpCompression>