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