Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web.Config transformation of custom config section

Does anybody know how to get the web.config transformation to replace a custom configuration section. I have set msbuild to verbose mode and the transformation simply ignores the existence of the custom section with a replace transform.

like image 546
redsquare Avatar asked Jan 29 '11 10:01

redsquare


People also ask

What is Web config transform?

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

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.

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

A web.config transformation does not care about custom configuration sections. It will do replacements on the whole web.config file.

Here is an example XML of a web.config replacement I used to set our memcached server ips:

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    <enyim.com>
        <memcached>
            <servers xdt:Transform="Replace">
                <add address="192.168.130.1" port="11211" />
                <add address="192.168.130.2" port="11211" />
                <add address="192.168.130.3" port="11211" />
            </servers>
        </memcached>
    </enyim.com>
</configuration>
like image 166
Paul Lemke Avatar answered Sep 30 '22 11:09

Paul Lemke