0

MVCアプリケーションには、開発環境用にセットアップされたweb.configがあり、新しいWCFサービスエンドポイントを挿入する必要がある変換ファイルがありますが、間違った場所に追加されているため、何かを見逃していると思います。

必要なものだけを表示するために、構成ファイルを削減しました。

私は次のように通常のweb.configを持っています:

<services>
  <!-- Report Service -->
  <service name="Core.ReportDataHost">
    <endpoint name="ReportDataHost" address="..." binding="customBinding" contract="..."/>
  </service>

  <!-- Authentication Service -->
  <service name="Core.AuthenticationHost">
    <endpoint name="AuthenticationHost" address="..." binding="customBinding" contract="..."/>
  </service>

</services>

次に、次のように変換ファイルを作成します。

<services>

  <service name="Core.AuthenticationHost">
    <endpoint xdt:Transform="Insert" address="" binding="customBinding" contract="..." />
  </service>

</services>

これにより、「AuthenticationHost」サービスに新しいエンドポイントが追加されると期待していましたが、最初のサービス「ReportDataHost」に追加されます。

私が欠けているアイデアはありますか?

4

1 に答える 1

1

トランスフォームはデフォルトでタグのみを使用し、属性は使用しないため、トランスフォームにname = "Core.AuthenticationHost"が含まれていても、それは無視され、最初に見つかったServiceタグを使用してServiceタグとのみ一致します。

タグにロケーターを追加して、<service>(最初のロケーターを使用するのではなく)どちらを使用するかがわかるようにします。ロケーターはタグの属性です:xdt:Locator="Match(attribute1,attribute2,...)"。この場合、name属性を照合する必要があります。

修正された変換は次のようになります。

<services>
  <service name="Core.AuthenticationHost" xdt:Locator="Match(name)">
    <endpoint xdt:Transform="Insert" address="" binding="customBinding" contract="..." />
  </service>
</services>

詳細については、MSDNの変換構文ページを参照してください。

于 2012-07-18T15:05:06.303 に答える