Question

I've got a simple ASP.NET MVC website. It has Debug, Testing and Release configuration modes.

We're using TFS as our source control and bug tracking, etc. Nice.

Now, we're about to embark on using Team Builds to automate some Continuous Intergration. The thing is, we're not sure how to make it so that if we want to make a DEBUG build, or a RELEASE build, it also drops the correct web.config file into the destination directory. Also, we have certain sections of the web.config file extracted to seperate files (eg. the connection string section or the machine key section, etc). Can the correct environment files be dropped correctly into the destination directory.

Was it helpful?

Solution

You could do a pre-build step

Say you have checked in

  • /Debug.Web.Config
  • /Release.Web.Config

You could write a pre-build step to check the build type and copy the proper .config file to

  • /Web.Config

Something like

cp $(ConfigurationName).Web.Config $(TargetDir)

On a side note, ASP.net 4.0 will have support for multiple Web.Configs

http://weblogs.asp.net/gunnarpeipman/archive/2009/06/03/visual-studio-2010-multiple-web-config-versions.aspx

OTHER TIPS

Incidentally, using either a pre-build or post-build step will not work under Team Foundation Server. It automatically configures security on the build directory to prevent any changes being made to configuration files during the build process, whether as pre-build events or as post-build events. The only result of using cp is to return an "Access denied" error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top