I am creating a nuget package where part of the result of installing the package is to modify my web.release.config.
I have no problem inserting elements into this file with my web.release.config.install.xdt, but I need to keep the xdt:Transform and xdt:Locator attributes on the elements I am inserting because these transforms will need to be run when the application is built for deployment.
So for instance when installing the nuget package I would like to see:
<add key="serilog:using" value="Serilog.Sinks.Seq" xdt:Transform="InsertIfMissing" xdt:Locator="Match(key)" />
show up in the web.release.config including the xdt:Transform and xdt:Locator attributes.
Is it possible to do this?
I don't believe what you are trying to do is supported by either msbuild or SlowCheetah. Most NuGet package owners dont know enough about their customers implementation to set values into environment specific configs. Additionally the transform tools where not written with NuGet in mind as they was built to serve a different need. Sorry for the bad news.
You may be able to use an init.ps1 powershell script to get this done (NuGet will run this script the first time the package is installed in the solution) but it will be less than clean.