A quite common task during the build process of an application is to change the configuration file with settings specific to test in on the testing environment or to release the product to customers.

NAnt has task that allow this: it can change the value of any attribute inside any XML file. You just need to be fluent with XPath in order to get the correct value to change.

<xmlpoke file="${testing.dir}\web.config"
     xpath="/configuration/appSettings/add[@key = 'ServerId']/@value"

This snippet include some example values: just change ServerId to setting key you want to change and CODECLIMBER to your setting's value.

And since the xmlpoke task can access anything with XPath, here is another example: change the tcp port for a remoting server:

<xmlpoke file="${MailPrimer.controlpanel.dir.testing}\web.config"
        application/channels/channel[@ref = 'tcp']/@port"

This solution can be improved reading new setting's values from an external XML file (using the xmlpeek task) instead of hardcoding them inside the build script, but the core of the solution is the xmlpoke NAnt task.