Non possibile senza codice di scrittura.
Tuttavia, la mia soluzione attuale è quella di misura il XDT Transform biblioteca, dal fondo seguendo il link: Extending XML (web.config) Config transformation
Ed ecco il mio esempio di CommentAppend
, CommentPrepend
che prendono commento testo come parametro di input, come credo altrimenti Insert
non può funzionare come il commento che avresti messo il tuo xdt:Transform="Insert"
verrà ignorato da XDT Transform in quanto è un commento.
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);
}
}
}
e l'ingresso web.Release.config
:
<security xdt:Transform="CommentPrepend(comment line 123)" >
</security>
<security xdt:Transform="CommentAppend(comment line 123)" >
</security>
E l'output:
<!--comment line 123--><security>
<requestFiltering>
<hiddenSegments>
<add segment="NWebsecConfig" />
<add segment="Logs" />
</hiddenSegments>
</requestFiltering>
</security><!--comment line 123-->
Attualmente sto usando riflettore a guardare Microsoft.Web.XmTransform viene fornito con Visual Studio V12.0 per capire come funziona, ma probabilmente è meglio guardare il source code itself
fonte
2016-12-08 23:53:34
[Vota] (https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/2578637-allow-inserting-comments-with-web-config-transform) per includere questa funzionalità in Visual Studio –