Convert Web.Config without changing any values

I am trying to configure the web.config conversion to change some values. I use this example cited by Octopus Deploy:

http://docs.octopusdeploy.com/display/OD/Configuration+files

ultra-slimmed down version of web.config:

<?xml version="1.0" ?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> <compilation debug="true" targetFramework="4.0"> </compilation> </system.web> </configuration> 

conversion:

 <?xml version="1.0" ?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <system.web> <compilation xdt:Transform="RemoveAttributes(debug)" /> </system.web> </configuration> 

conclusion:

 <?xml version="1.0"?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> <compilation debug="true" targetFramework="4.0"> </compilation> </system.web> </configuration> 

I use this tool to preview the conversion: https://webconfigtransformationtester.apphb.com/

as you can see, does nothing. I looked at a lot of examples, but obviously I missed something. Any help would be greatly appreciated.

(I also tried this with no luck):

 <?xml version="1.0"?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <system.web> <compilation debug="false" xdt:Transform="Replace"> </compilation > </system.web> </configuration> 
+5
source share
1 answer

The conversion works in accordance with the specified online browsing tool for web.config conversions https://webconfigtransformationtester.apphb.com/ when changing the namespace on the Internet. config from

 <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> 

to

 <configuration xmlns:xdt="http://schemas.microsoft.com/.NetConfiguration/v2.0"> 

When is this conversion

 <?xml version="1.0" ?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <system.web> <compilation xdt:Transform="RemoveAttributes(debug)" /> </system.web> </configuration> 

applies to configured web.config

 <?xml version="1.0" ?> <configuration xmlns:xdt="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> <compilation debug="true" targetFramework="4.0"> </compilation> </system.web> </configuration> 

the debug attribute is removed from the result:

 <?xml version="1.0"?> <configuration xmlns:xdt="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> <compilation targetFramework="4.0"> </compilation> </system.web> </configuration> 

Update: As mentioned in the comments, the configuration of the web.config file should not have any namespace at all. Instead, add this import

 <xdt:Import assembly="AppHarbor.TransformTester" namespace="AppHarbor.TransformTester.Transforms"/> 

to the conversion file (at least when testing with the specified online transformation test):

 <?xml version="1.0"?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <xdt:Import assembly="AppHarbor.TransformTester" namespace="AppHarbor.TransformTester.Transforms"/> <system.web> <compilation xdt:Transform="RemoveAttributes(debug)" /> </system.web> </configuration> 
+3
source

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


All Articles