Using web.config transforms, I want to make sure and include a comment at top of the resulting web.config to indicate which transform file(configuration) was used to generate it.
I don't see a way to include comments from the transform files, can this be done?
EDIT:
It appears that all comments in the transform files are stripped.
Answers. ctl K + C combination to comment that line... to uncomment ctl K + U combination is used.
XDT is a simple and straight forward method of transforming the web. config during publishing/packaging. Transformation actions are specified using XML attributes defined in the XML-Document-Transform namespace, that is mapped to the xdt prefix.
A Web. config transformation file contains XML markup that specifies how to change the Web. config file when it is deployed. You can specify different changes for specific build configurations and for specific publish profiles.
The following does not directly answer how to add or preserve comments, but it might get you toward the goal of knowing which transform was used. Admittedly, it feels a little strange, so keep your eyes open for other answers. It's just the first thing that came to mind.
I don't know of a way to preserve the comments from transforms, but you could always insert a dummy application setting to deliver the information. The app doesn't actually have to use it for anything =p
Here I have it being inserted by the transform, assuming it isn't in the main web.config. You could just as easily do a Replace.
<appSettings>
<add key="WhichTransformWasUsed" value="Production" xdt:Transform="Insert"/>
</appSettings>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With