Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

web.config transform: Add XML comment to indicate which configuration was used

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.

like image 298
BoxOfNotGoodery Avatar asked Jan 18 '12 18:01

BoxOfNotGoodery


People also ask

How do I comment in web config?

Answers. ctl K + C combination to comment that line... to uncomment ctl K + U combination is used.

What is Xdt transformation?

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.

How does web config transform work?

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.


1 Answers

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>
like image 126
David Ruttka Avatar answered Oct 25 '22 02:10

David Ruttka