I am trying to determine a good way to handle web.config files that differ between environments. My workstation, development server, intermediate server, and production server have slightly different settings in the web.config file. I would like to keep various web.config files under version control. In addition to history, this makes it easy to move files between servers. What is the best way to handle this situation?
Here is my current strategy / procedure:
- My project contains 4 configuration files: web.config, web_local.config, web_dev.config, web_stg.config and web_prod.config.
- Using SVN settings, web.config is ignored.
- Files are moved between servers using SVN to register and register files.
- After using SVN to upgrade to the latest copy, the web.config file on each system is replaced with the corresponding web _ ####. config. (I do this by copying the file to a new directory, renaming it to web.config and dragging it back to the original directory to replace the working copy.)
This works, but it doesn't seem like the best way to get closer to things.
Here are the problems that come to mind:
- The last step in which the corresponding .config file is copied to a new directory, renamed and used to replace the current one, seems clumsy and error prone. Two of these sites are on the same machine, and it is easier than you might think to use the wrong configuration file for replacement.
- Web configuration files _ ####. should be hidden from public access by server settings, but it is still impractical to reset all configuration files __ ###. config from SVN for each project, when only one is needed for each site. It would be better if I could only get the necessary file from SVN. I can manually delete unused files after updating the SVN directory, but this causes the SVN to check the directory in red due to missing files. I want the green checked directory to only have the necessary files, if possible. Can I configure each directory to load a different set of files?
What strategy / technique / procedure do other people use to deal with this situation?
source share