2016-12-23 74 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>