2016-12-23 76 views
0

我在使用NuGet之前使用this网站来测试我的XDT转换。当我有这个配置XDT转换删除错误的条目

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.web> 
    <httpModules> 
     <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> 
     <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" /> 
     <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" /> 
    </httpModules> 
    </system.web> 
</configuration> 

,并使用此转换:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
    <system.web> 
    <httpModules> 
     <add name="ErrorLog" xdt:Transform="Remove" />  
    </httpModules> 
    </system.web> 
</configuration> 

结果是这样的输出:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.web> 
    <httpModules> 

     <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" /> 
     <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" /> 
    </httpModules> 
    </system.web> 
</configuration> 

我不明白为什么进入ApplicationInsightsWebTracking被删除,而不是错误日志。在NuGet包中使用此转换时(在删除包时)我得到了相同的结果。如何改变工作中的转换?

回答

1

你需要明确地告诉XDT通过name匹配属性,以及通过使用xdt:Locator="Match()",否则只能元件位置/路径将被考虑匹配问题(这就是为什么第一add元素得到了初步删除):

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
    <system.web> 
    <httpModules> 
     <add name="ErrorLog" xdt:Locator="Match(name)" xdt:Transform="Remove" />  
    </httpModules> 
    </system.web> 
</configuration>