Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Working with Web.Release.config (Web.config transformation)

In my Web.config file have the following setup:

<add key="ClientMail" value="[email protected]"/>

In my file I Web.Release.config:

<appSettings>
    <add key="ClientMail"
                xdt:Transform="SetAttributes"
                xdt:Locator="Match(value)"
                value="[email protected]"/>
</appSettings>

How do I get when running the site in Release mode, the settings are being applied in Web.Release.config?

In this case I need to change the value of a setting in <appSettings>

like image 415
ridermansb Avatar asked Oct 06 '11 21:10

ridermansb


People also ask

How does web config transform work?

A Web. config transformation file contains XML markup that specifies how to change the Web. config file when it is deployed. You can specify different changes for specific build configurations and for specific publish profiles.

How do I enable 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).

What is Xdt transformation?

XDT is a simple and straight forward method of transforming the web. config during publishing/packaging. Transformation actions are specified using XML attributes defined in the XML-Document-Transform namespace, that is mapped to the xdt prefix.

What is Xdt transform replace?

A Transform attribute on a parent element can affect child elements even if no Transform is specified for them. For example, if you put the attribute xdt:Transform="Replace" in the system. web element, all the elements that are children of the system. web element are replaced with the content from the transform file.


1 Answers

I believe this only applies when publishing a release. Otherwise you need to include a build event to cause a merge in a config build for a named build config. If you are interested in that let me know and I'll find my post on here regarding that.

Learn about web config transformations here: http://weblogs.asp.net/gunnarpeipman/archive/2009/06/16/visual-studio-2010-web-config-transforms.aspx

like image 82
Adam Tuliper Avatar answered Nov 15 '22 07:11

Adam Tuliper