I'm trying to update an existing appSettings in my web.config. I don't want to replace the entire value, but append my new value to the end. Is this possible?
Current value:
<add key="umbracoReservedPaths" value="~/umbraco,~/install/" />
Required value:
<add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/signalr" />
This is what I have currently in my transform file:
<add key="umbracoReservedPaths" value=",~/signalr" xdt:Transform="SetAttributes(value)" xdt:Locator="Match(key)"/>
The xdt:Transform="RemoveAttributes(debug)" attribute specifies that you want the debug attribute to be removed from the system. web/compilation element in the deployed Web. config file. This will be done every time you deploy a Release build.
Switching configuration based on configuration is a perfect use of transformations. Web. config transformations are implemented using a markup language called XML Document Transform - XDT for short. XDT is an XML-based document format invented by Microsoft and used to describe changes to a Web.
If you have a web application project, Right-click on web. config and choose Add Config Transform. This will add any config transforms that are missing from your project based on build configurations (i.e. if you have Production and Staging build configs, both will get a transform added).
If you are using the extension Configuration Transform go to Build > Configuration Manager and find the Configuration dropdown for the project of which you want to change the app config. You can then select the edit and rename the build configurations for that project.
You can insert a new element or modify an existing one but XDT transforms do not have the ability to append an attributes value to the original. MSDN Web.config supported transformations
Insert:
<add key="ExampleKey" value="true"
xdt:Transform="Insert" />
Update value attribute:
<add key="ExampleKey" value="true"
xdt:Transform="SetAttributes(value)" xdt:Locator="Match(key)"/>
Replace element:
<add key="ExampleKey" value="true"
xdt:Transform="Replace" xdt:Locator="Match(key)"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With