Web.config conversion - surrounding elements

I am using web.config conversions available through VS2010. In this case, I wonder if it is possible to "surround" the element with another during the conversion. Here is an example:

default web.config contains:

<configuration> <system.web> .... </system.web> </configuration> 

My converted file should contain

 <configuration> <location inheritInChildApplications="false"> <system.web> ... </system.web> </location> </configuration> 

So essentially, I want to β€œwrap” the system.web element with a location element. My only thought was to make the conversion so that I insert before and after, like:

 <location inheritInChildApplications="false" xdt:Transform="InsertBefore(/configuration/system.web)"> </location xdt:Transform="InsertAfter(/configuration/system.web)"> 

But the closing location element is invalid xml according to VS (I guess due to the Transform attribute). Just inserting an element of a self-closing location before system.web doesn't help, because the resulting system.web is still not "surrounded".

+8
web-config msbuild web-config-transform
source share
2 answers

Currently, it will not be possible to do this with the web.config transform, but it really should be feasible if you wrote a custom transform ... Documentation on how to write custom transformations is currently being updated, but it hasn’t come out yet .. .

I will send it as soon as it is available ...

+2
source share

If you add an empty location tag to your webconfig, where would you like it to be inefficient.

Then you can put this in your conversion file in the same place as another:

 <location xdt:Locator="XPath(some xpath expression)" inheritChildApplications="false" xdt:Transform="SetAttributes(inheritChildApplications)"> 

with a closing tag too and so on.

+2
source share

Source: https://habr.com/ru/post/650225/


All Articles