Web.config转换:如何将转换应用于与Locator表达式匹配的所有节点?

Cle*_*ent 8 children web-config nodes web-config-transform xdt-transform

我最近在visual studio 2010的web部署工具中发现了web.config自动转换.它运行良好,但我有一个我似乎无法工作的场景.假设我有以下根Web.config

<services>
  <service name="Service1">
    <endpoint address="" binding="customBinding" bindingConfiguration="LargeBufferBinding"
      contract="Service1" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
  <service name="Service2">
    <endpoint address="" binding="customBinding" bindingConfiguration="LargeBufferBinding"
      contract="Service2" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
  <service name="Service3">
    <endpoint address="" binding="customBinding" bindingConfiguration="LargeBufferBinding"
      contract="Service3" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
Run Code Online (Sandbox Code Playgroud)

对于我的Web.Release.config,我希望删除所有带有mexHttpBinding绑定的端点节点.

我在我的Web.Release.config中使用了以下内容:

<services>
  <service>
    <endpoint binding="mexHttpBinding" xdt:Locator="Match(binding)" xdt:Transform="Remove" />
  </service>
</services>
Run Code Online (Sandbox Code Playgroud)

但是,这只会删除Service1中的第一个匹配项,但不会删除以下匹配项.我尝试了在端点和服务节点上定位节点的各种方法,但只有第一个匹配才被替换.

有没有办法让所有<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />被删除?

谢谢.

Ben*_*ard 12

我刚试过这个并且使用RemoveAll而不是Remove似乎可以解决这个问题:

<services>
  <service>
    <endpoint binding="mexHttpBinding" xdt:Locator="Match(binding)" xdt:Transform="RemoveAll" />
  </service>
</services>
Run Code Online (Sandbox Code Playgroud)