8

最近、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 の最初の一致のみを削除し、次の一致は削除しません。エンドポイントとサービスノードでノードを見つけるさまざまな方法を試しましたが、最初に一致したものだけが置き換えられます。

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />すべてを削除する方法はありますか?

ありがとう。

4

1 に答える 1

12

私はこれを試してみましたが、Removeの代わりにRemoveAllを使用するとうまくいくようです:

<services>
  <service>
    <endpoint binding="mexHttpBinding" xdt:Locator="Match(binding)" xdt:Transform="RemoveAll" />
  </service>
</services>
于 2011-02-09T13:23:41.167 に答える