redsquare
redsquare

Reputation: 78667

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.

Upvotes: 14

Views: 4869

Answers (2)

Sebastian Castaldi
Sebastian Castaldi

Reputation: 9004

In case you have the same issue I was having... I wanted to kick myself!

During Publish, make sure you select the environment :)

enter image description here

Upvotes: 0

Paul Lemke
Paul Lemke

Reputation: 5534

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>

Upvotes: 15

Related Questions