8

我最近在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>

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

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

<services>
  <service>
    <endpoint binding="mexHttpBinding" xdt:Locator="Match(binding)" xdt:Transform="Remove" />
  </service>
</services>

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

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

谢谢。

4

1 回答 1

12

我刚刚尝试过,使用 RemoveAll 而不是 Remove 似乎可以解决问题:

<services>
  <service>
    <endpoint binding="mexHttpBinding" xdt:Locator="Match(binding)" xdt:Transform="RemoveAll" />
  </service>
</services>
于 2011-02-09T13:23:41.167 回答