Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XDT Transform of web.config is Append possible

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)"/>
like image 618
Ian Houghton Avatar asked Dec 13 '16 17:12

Ian Houghton


People also ask

What is Xdt transform in web config?

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.

How does web config transform work?

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.

How do I create a new transformation in web config?

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).

How do I rename a web config transform?

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.


1 Answers

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)"/>
like image 76
Anth12 Avatar answered Oct 17 '22 18:10

Anth12