Search code examples
asp.netmsbuildweb-configmsdeployweb-config-transform

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.


Solution

  • 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>