views:

224

answers:

4

I am working on a web project as a Web Site, rather than a Web Application. How can I use a different config file depending on where it is hosted from, so the local version uses my local SQL install, but the published version uses the live database? e.g. connectionStrings.config ignored (not published), connectionStrings.live.config published as connectionStrings.config

I see a policy file option, would that be something able to do this?

+1  A: 

Post Build Event which swaps the config over?

you can have a different post build event depending on your build configuration, each can copy a different config if needed.

Saint Gerbil
Can't see a post build event option, as I just open it as a website project, e.g. 'file' > 'open' > 'website'
Sam
I think Saint is referring to development vs. production. By default you config should point to dev, then change when you deploy to production (assuming you're deploying prebuilt code)
Mike Robinson
Ahh sorry you are working on a web site project, unfortunatly these are the only project types (which build) which dont have a pre\post build event.
Saint Gerbil
+3  A: 

Use a MSBuild or NAnt script for different builds.

rball
+1 for Nant and/or MSBuild. Works great along with web deployment projects as well.
JamesEggers
+2  A: 

You can use a Web Deployment project. Check out ScottGu's blog post.

Robert S.
How about for Visual Studio 2005?
Sam
Web deployment projects existed for VS2005 as well
Chris Lively
+3  A: 

There are several options regarding this. The simplest is to use a web deployment project. The ScottGu's post goes into more detail on this.

For larger projects you will need something like Nant or MSBuild and CruiseControl or TeamBuild.

I also posted something here a while back on supporting complex config deployments

Dan