Transformación web.config: ¿cómo aplicar una transformación a todos los nodos que coinciden con una expresión de localizador?

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 ser eliminado.

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.

¿Hay alguna manera de obtener todos los <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> to be removed ?

Gracias.

preguntado el 09 de enero de 11 a las 01:01

Clement just as a note you should accept the answer below rather than just comment on it. -

1 Respuestas

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>

Respondido 09 Feb 11, 16:02

Is there something similar that would work for Insert All? InsertAll isn't recognized. - grimus

@grimus did you find any solution to the "Insert All" question? - Vidar Kongsli

Since this is over 3 years old, I posted another pregunta that pertains to this code, if anyone could take a look, that'd be great. - Código Maverick

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.