Web.config 转换:如何将转换应用于与定位器表达式匹配的所有节点?
我最近发现了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 中的第一个匹配项,但不会删除以下匹配项。 我尝试了在端点和服务节点上定位节点的各种方法,但只有第一个匹配项被替换。
有没有办法让所有
被删除?
谢谢。
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>
For my Web.Release.config, I want all the endpoint nodes with a binding of mexHttpBinding to be removed.
I've used the following in my Web.Release.config:
<services>
<service>
<endpoint binding="mexHttpBinding" xdt:Locator="Match(binding)" xdt:Transform="Remove" />
</service>
</services>
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.
Is there a way to get all the <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
to be removed ?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚尝试过这个,使用RemoveAll而不是Remove似乎可以解决问题:
I've just tried this and using RemoveAll instead of Remove seems to do the trick: