Transforming Config Files

Recently I was experimenting with configuration transformations.  The actual use and mechanics of config transformations is beyond the scope of this discussion, but more information is available here: How to: Transform Web.config When Deploying a Web Application Project.  I added the transforms to a legacy web project, edited the various files, every thing was working swimingly.

And then I tried to build the solution through TFS Build.

The first challenge I encountered was the transform was trying to…well…transform.  The system was attempting to create the output web.config file, which is under source control and not writeable.  The solution to this is to exclude the web.config file from source control.

The next challenge was that because the system considers the web.debug.config, web.release.config, et. al. to be dependent on the parent web.config, they also get excluded from source control.  The solution to this one was a bit more elusive, since all the config files are considered to be a single unit.  Exclude one, exclude them all.  Turns out the excluded-ness is stored in the .vbproj.vspcc file in the web project.

"FILE_VERSION" = "9237"
"EXCLUDED_FILE0" = "web.config"
"EXCLUDED_FILE1" = "web.debug.config"
"EXCLUDED_FILE2" = "web.release.config"
"EXCLUDED_FILE3" = "web.template.config"

Simply remove the EXCLUDED_FILE1/2/3 lines, change the NUMBER_OF_EXCLUDED_FILES to 1 and life is good.