Impossible without writing code.
However, my current solution is to extend the XDT Transform library, mainly following the link: XML Extension (web.config) Configuration Conversion
And here is my CommentAppend
example, CommentPrepend
, which takes the comment text as an input parameter, since I believe that otherwise Insert
itself cannot work as a comment that you would put on your xdt:Transform="Insert"
, XDT will be ignored Transform as it is a comment.
internal class CommentInsert: Transform { protected override void Apply() { if (this.TargetNode != null && this.TargetNode.OwnerDocument != null) { var commentNode = this.TargetNode.OwnerDocument.CreateComment(this.ArgumentString); this.TargetNode.AppendChild(commentNode); } } } internal class CommentAppend: Transform { protected override void Apply() { if (this.TargetNode != null && this.TargetNode.OwnerDocument != null) { var commentNode = this.TargetNode.OwnerDocument.CreateComment(this.ArgumentString); this.TargetNode.ParentNode.InsertAfter(commentNode, this.TargetNode); } } }
And input web.Release.config
:
<security xdt:Transform="CommentPrepend(comment line 123)" > </security> <security xdt:Transform="CommentAppend(comment line 123)" > </security>
And the conclusion:
<security> <requestFiltering> <hiddenSegments> <add segment="NWebsecConfig" /> <add segment="Logs" /> </hiddenSegments> </requestFiltering> </security>
I am currently using Reflector to view Microsoft.Web.XmTransform comes with Visual Studio V12.0 to figure out how this works, but it's probably best to look at the source code itself
Paul l
source share