Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web.config transformation: how to apply a transformation to all node matching a Locator expression?

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.

like image 289
Clement Avatar asked Jan 09 '11 01:01

Clement


1 Answers

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>
like image 152
Ben Shepheard Avatar answered Oct 18 '22 21:10

Ben Shepheard