Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XDT Transforms - Transforming the transform

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?

like image 665
Kelly Avatar asked Jun 19 '15 19:06

Kelly


1 Answers

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.

like image 71
P. Roe Avatar answered Sep 19 '22 13:09

P. Roe