微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我最近在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”/>即将被删除

谢谢.

解决方法

我刚试过这个并使用RemoveAll而不是Remove似乎可以解决这个问题:
<services>
  <service>
    <endpoint binding="mexHttpBinding" xdt:Locator="Match(binding)" xdt:Transform="RemoveAll" />
  </service>
</services>

原文地址:https://www.jb51.cc/html/227519.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐