Config元素插入两次,何时应插入一次

时间:2018-09-26 05:52:55

标签: xml nuget xdt-transform

我正在创建NuGet软件包,并通过我的web.config.install.xdt文件对软件包安装进行一些配置转换。

该文件具有以下代码:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.serviceModel xdt:Transform="InsertIfMissing">
    <behaviors xdt:Transform="InsertIfMissing">
      <endpointBehaviors xdt:Transform="InsertIfMissing">
        <behavior name="customBehaviourOne" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)">
          <custom entityType="service" xdt:Transform="Insert" xdt:Locator="Match(entityType)"/>
        </behavior>
        <behavior name="customBehaviourTwo" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)">
          <custom entityType="service" xdt:Transform="Insert" xdt:Locator="Match(entityType)" />
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

当我安装软件包时,下面是web.config,您可以在下面看到我得到的重复值。

<system.serviceModel>
    <behaviors>
        <endpointBehaviors>
            <behavior name="customBehaviourOne">
                <custom entityType="service" />
                <custom entityType="service" />
            </behavior>
            <behavior name="customBehaviourTwo">
                <custom entityType="service" />
                <custom entityType="service" />
            </behavior>
        </endpointBehaviors>
    </behaviors>
</system.serviceModel>

我对为什么要复制<custom entityType="service" />感到有些困惑,我希望只插入一次。

0 个答案:

没有答案