I'm a big fan of using MSBuild, in particular the MSBuild Community Tasks (http://msbuildtasks.tigris.org/) and there is an XSLT task to transform the web.config with the appropriate connection string settings, etc.
I keep these tasks handy:
<Target Name="Configs">
<Xslt RootTag="" Inputs="web.config" Output="Web.$(COMPUTERNAME).config" Xsl="web.config.$(COMPUTERNAME).xslt" Condition="Exists('web.config.$(COMPUTERNAME).xslt')" />
Obviously this isn't 100% what you're after, it's so each dev can have their own web.config.
But there's no reason you couldn't use the above principle to have multiple build configurations which applies the right XSLT.
My XSLT looks like this:
<?xml version="1.0" encoding="utf-8"?>
<!-- Dev -->
<xsl:template match="/configuration/connectionStrings/add[@name='MyConnectionString']/@connectionString">
<xsl:attribute name="connectionString">Data Source=MyServer;Initial Catalog=MyBD;User ID=user;password=pwd</xsl:attribute>
</xsl:template>
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
answered 2008-09-25T12:14:22.137