Web.config转换:如何对与Locator表达式匹配的所有节点应用转换? [英] Web.config transformation: how to apply a transformation to all node matching a Locator expression?

查看:80
本文介绍了Web.config转换:如何对与Locator表达式匹配的所有节点应用转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在Visual Studio 2010的Web部署工具中发现了web.config自动转换. 它运行良好,但是我遇到了无法正常工作的情况. 假设我具有以下根Web.config

I've recently discovered the web.config automatic transformation in the web deploy tool of visual studio 2010. It's working well, but I have a scenario I can't seem to get working. Assume I have the following root 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的终结点节点.

For my Web.Release.config, I want all the endpoint nodes with a binding of mexHttpBinding to be removed.

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

I've used the following in my Web.Release.config:

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

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

However, this will only remove the first match, in the Service1, but not the following ones. I've tried various way of locating the node, on the endpoint and service node, but only the first match ever gets replaced.

是否有办法将所有<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />删除?

Is there a way to get all the <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> to be removed ?

谢谢.

推荐答案

我刚刚尝试过此方法,并且使用RemoveAll代替Remove似乎可以解决问题:

I've just tried this and using RemoveAll instead of Remove seems to do the trick:

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

这篇关于Web.config转换:如何对与Locator表达式匹配的所有节点应用转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆