Friday, February 28, 2003 8:59 AM HomeSkillet

Development vs Production web.config files

Well I just find another one (It's new for me). What I do is after a first copy of my application to my Production server, everytime I need to update the site I exclude Webconfig from the project, copy and include again WebConfig. [ heLP .Net Blog ]

I so something similar to this but instead of excluding the web.config I sets its build action to none. When I am ready to deploy, I use the copy project feature of VS.NET select the copy only the files needed for this application option and the click ok. In the copied project folder, I make any changes I need to the web.config file to prepare it for deployement (i.e. update paths, etc.). Then in my main project in VS.NET, I set the web.config's build action to none. This prevents my production web.config from being overwritten by my dev version.

Filed under:

Comments

# re: Development vs Production web.config files

Sunday, March 16, 2003 12:46 PM by John St. Clair

Man is that a pain. You must be using C# :)

This is one (and probably the only) feature I enjoy in VB.NET web projects -- in the project properties, you can specify a particular _.config file for each Solution/project configuration (i.e., debug, release, staging, production, etc).

Actually, you can do this in C# too, but you need to hack the project file's XML manually. I believe it has been added in Everett.

# re: Development vs Production web.config files

Thursday, June 26, 2003 2:25 AM by Byron

Another way is just put the config files in excluded subfolders and add in the file that you want for each install project.

# re: Development vs Production web.config files

Friday, January 30, 2004 12:59 PM by Allan McLemore

A nice solution I use involves deployment projects. Basically you:

1. create a folder called _Config in your web project and store your config files here.
i.e. DevWeb.config, StagingWeb.config, ProductionWeb.config

2. create a custom installer class in your web project. Add a method to fire on the committed event of the installation that copies the config files for the instance that you are installing from the _Config folder.

3. create a Web deployment project

4. Add a GUI control to the install routine, that has radio buttons for the application instance (dev,staging, production).

5. Add a custom action to your your deployment project to fire on the Commit action of the installer. Pass in the application instance radio button value (dev, staging, production)

6. The installer class code that you wrote will copy the correct instance file and overwrite whatever Web.config file was there.

There's a lot of details to this. This is just a brief overview of the technique. But, it works with all types of projects, web, .exe, services, etc. That is why I use this technique.

Leave a Comment

(required) 
(required) 
(optional)
(required)