nugetxdt-transform

Web.config.transform for Nuget Package Re-inserts Existing Settings On Update


I'm creating my own Nuget package, and I'm struggling with some issues related to applying updates. In my Nuget Package I'm adding app settings to the web.config like this...

 <add key="errorFileName" value="[errorFileName]" />
 <add key="errorFilePath" value="[errorFilePath]" />
 <add key="fileLoggingEnable" value="true" /> 

When the package is first installed, the developer needs to set an actual file name and path. When they update the package, the transform reinserts these settings apparently not recognizing the existence of these settings once they've been altered.

I've done a little research on web.config.install.xdt, but I don't understand how to ignore a matched element, i.e. DON'T Insert the element if one matches. I need to do something like this...

<add name="AWLT" connectionString="newstring" 
  providerName="newprovider"
  xdt:Transform="Ignore" <-- This does not exist 
  xdt:Locator="Match(name)" />

What have I missed? Hopefully, that makes since. Thanks in advance.


Solution

  • The answer was using this in my elements in an install.xdt file.

    xdt:Transform="InsertIfMissing"