我最近在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,我希望删除所有绑定(bind)了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>
关于web-config - Web.config转换: how to apply a transformation to all node matching a Locator expression?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4637107/