8

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.

Code Maverick
  • 20,171
  • 12
  • 62
  • 114
Clement
  • 3,990
  • 4
  • 43
  • 44

1 Answers1

12

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>
Ben Shepheard
  • 479
  • 3
  • 10
  • Is there something similar that would work for Insert All? InsertAll isn't recognized. – grimus Jun 07 '11 at 16:09
  • @grimus did you find any solution to the "Insert All" question? – Vidar Kongsli Oct 05 '11 at 06:38
  • Same question: http://stackoverflow.com/questions/12809264/inserting-multiple-items-with-web-config-transforms – alexey Jan 16 '13 at 08:13
  • Since this is over 3 years old, I posted another [question](http://stackoverflow.com/q/26808096/682480) that pertains to this code, if anyone could take a look, that'd be great. – Code Maverick Nov 07 '14 at 19:22