Those who know me know that I hate repetition. Reducing duplication and improving productivity is usually the driving force behind much that I do with computers (other than my day job of software development).
After installing Visual Studio 2008 and new versions of Resharper, I realized that I was, once again, going to have to reset all of my preferences. Tired of dealing with this, I set on a mission to formulate a process to consolidate my Visual Studio, Macro, Resharper, and any other add-on settings into a single, convenient, static location so I would never have to re-create my preferences again!
Using a few free utilities, I was able to come up with a pretty nice solution that works well for me (and, hopefully, you as well).
Step 1 - Visual Studio Preferences Paths
To ensure that Visual Studio saves any preference changes to our centralized settings location, we need to change Visual Studio's preferences to point to a nicer location than My Documents (man, I hate the My Documents folder). The spots that you want to change are the "Projects and Solutions" directories and "Import and Export Settings".
I change locations to a separate partition/drive because I like to keep my operating system partition separate from my data partition. I can then freely re-install my OS without worrying about all of the data that would be overwritten in the process (this is why I don't like the My Documents, My Pictures, etc.)


You will probably also want to include the new path to your Visual Studio Add-ins folder (in the new, centralized location)

Macro Projects
The Macro Projects have their own IDE environment whose preferences also need to be set to point to the centralized location. In the Visual Studio IDE, press ALT+F11 to open the Macro IDE. Open the Tools -> Options menu and set the Projects and Solutions locations to the same as the Visual Studio IDE paths.
I also open up the Macro Explorer (ALT+F8) in the Visual Studio IDE and create a new Macro project. I then set it as the recording project (so my macros are also centralized and versioned). When creating your new Macro Project, ensure that the path is pointing to your centralized DevAppData directory (it should if you've properly set the Macro IDE preferences).


Step 2 - Version Controlled Settings
The next step was to ensure that I could save my settings and revert to previous versions at any time. Enter Subversion / TortoiseSVN. If you're not using Subversion as a version control system for your development, START NOW! It's fantastic. Subversion / TortoiseSVN / VisualSVN makes for zero-friction, rock-solid Visual Studio-integrated version control.
Now that I've moved my Visual Studio settings to a new folder, I can add them to my Subversion repository using the method I previously blogged about. If you don't already have a Subversion repository, install one easily using the FREE VisualSVNServer download from VisualSVN!
Step 3 - Consolidating Other Settings
So, you've got your Visual Studio settings moved to a safe-from-reinstall location and imported into Subversion. What about all of the other supporting applications and their settings?
Applications usually store their settings in the install directory, the registry (yuck), or the %APPDATA% folder (if not on a network with roaming profiles, this location is usually C:\Documents and Settings\<your username>\Application Data\).
With all of these applications storing their settings in various locations, how can we manage them all in one convenient location?? (This is the part that I really like. :) )
Junctions
There is a feature in the Unix file system, called symbolic links, that allows you to create multiple "pointers" to one location on the file system. It is not very well known that the NTFS file system has had similar features since NTFS v3.0 (Windows 2000, Windows XP, Windows Server 2003, and higher). The feature that we are interested in is a "Directory Junction". I like to think of a junction as a "wormhole" from one directory to another. The great thing about a junction is that a change in the junction directory's contents will show up in the original directory. As far as the OS is concerned, they are directories at different paths, but the contents come from the same location.
There are many tools to help you create and manage junctions in Windows. The one that I like to use is Hardlink Shell Extension which allows me to manage the junction points with a context menu in Windows Explorer. Using Hardlink Shell Extension, I create "wormholes" to application settings directories from within my consolidated, version-controlled settings directory (I actually have to create the junction in reverse to play well with Subversion but I'll get to that).
Playing nicely with Subversion
Subversion doesn't like junctions in its structure (you get an error when trying to commit). To combat this, I simply copy the original setting folder that I wish to consolidate into my centralized location. Then, I make a junction from the centralized location back to the application's settings directory.
Let's use the Visual Studio "Schemas" directory as an example. I like to make a junction to the Schemas folder in my centralized settings folder so I can easily add new .xsd files for intelli-sense, such as NHibernate schemas. Instead of searching through C:\Program Files\Microsoft Visual Studio...bla bla bla, I know I can drop new schemas in my centralized "Schemas" junction and Visual Studio will pick them up.
-
First, copy the Schemas folder to your centralized settings location. For VS2008, you can find it at "C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas".
-
Now, rename "C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas" to "C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas.bak" (or delete the Schemas folder. I like to make a backup, just in case).
-
From your centralized settings folder, pick the newly copied "Schemas" folder as the junction link source

- Now, drop the junction at the path where Visual Studio expects to find these Schemas ("C:\Program Files\Microsoft Visual Studio 9.0\Xml")
By looking at the "Schema" folder's properties, we can see that the junction Target is our centralized settings folder (D:\DevAppData\Studio Settings\Visual Studio 2008\Schemas).
Conclusion
When all is said and done, you should now have a nice, centralized, version-controlled Visual Studio (and associated application) settings location. You should never again have to waste time re-configuring your development environment preferences!!
