I am using this site to test my XDT transformations before using in NuGet. When i have this config
<?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>
And use this transform:
<?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>
The result is this output:
<?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>
I do not understand why the entry ApplicationInsightsWebTracking is removed and not ErrorLog. I got the same results when using this transformation in a NuGet package (when removing the package). How to change the transformation in a working one?
You need to explicitly tell XDT to match by
name
attribute as well, by usingxdt:Locator="Match()"
, otherwise only the element location/path will be considered for matching (that's why the firstadd
element got removed initially) :