All of us Delphi developers are probably in the same boat when it comes to handling multiple projects each with different versions of different IDE packages. Package collisions, error messages and unloadable forms are a normality and to be blunt they are a pita. I used to solve that issue by running numerous VMWare sessions but the size of the disk images and the resources used by running several of these simultanously was huge.
But... there's another solution!
Say hello to the little known -r switch ...
This tiny 2 letter option will make your life much easier by setting the registry configuration root of Delphi (version 5 and higher). How does it work? Very simple. Just start Delphi like this [but don't do that just right now]
bds.exe -rMyConfig
and you will get a brand spanking new instance of Delphi started with the installation defaults (technically it's the settings stored in the local machine branch of the windows registry). That means that Delphi loads all assemblies, packages, environment settings and desktops from a different place and thus allows you have as many parallel configurations as you wish.
Now I'm sure you can see how one can benefit from that.
How to best use it
First let's look where the settings are stored. If you start Delphi from the original shortcut it will load its settings (mainly) from two places. One is the registry, specifically (for the new Galileo IDE)
HKEY_CURRENT_USER\Software\Borland\BDS
and the users application data directory which is (on my Windows 2008)
C:\Users\Administrator\AppData\Roaming\Borland\BDS
If we now start Delphi like mentioned above with the -rMyConfig switch the settings are actually loaded from
HKEY_CURRENT_USER\Software\Borland\MyConfig
and
C:\Users\Administrator\AppData\Roaming\Borland\MyConfig
Now that we know this, it is simple to make proper use of it. Let's say you want to save your current Delphi configuration as MyConfig. Simply open the registry editor, look for the default node (see above) and export the whole node. Then replace BDS with MyConfig in the exported file, and import the just exported file back. Voila, you have a copy of the settings. If you also want to copy your environment settings, desktops and repository just copy the whole BDS folder in the application data directory to a new directory MyConfig.
Once you're done, create a new Shortcut on your desktop or folder, and simply add
"C:\Program Files\CodeGear\RAD Studio\5.0\bin\bds.exe" -rMyConfig
When you run from this new shortcut, you can (un)install packages etc, change library paths etc, and it will all be confined to the newly created configuration.
Combining switches
Delphi has some other nice switches like -p to start a specific personality. Combining these switches with the -r switch works just fine. On my machine I have for example:
"C:\Program Files\CodeGear\RAD Studio\5.0\bin\bds.exe" -rBDS2007NX3Test -pDelphi
"C:\Program Files\CodeGear\RAD Studio\5.0\bin\bds.exe" -rBDS2007NX2EM -pDelphi
"C:\Program Files\CodeGear\RAD Studio\5.0\bin\bds.exe" -rBDS2007NX3Eco4 -pDelphiDotNet
The first starts a minimal Delphi32 personality with the NX3 packages installed and the unit test project open. The second start Delphi32 with NX2 and a lot of thirdparty components loaded and the Enterprise Manager project opened. The third starts Delphi.NET with the NX3 support assembly for ECO4 and of course ECO loaded.
Mind you, I still have one VMWare development session per major Delphi release to avoid any complications, as well as clean test sessions. On a daily base though I now usually just start one session, and use shortcuts to start multiple different configurations.
Caveat
Be careful with automation tools like FinalBuilder. Since you potentially have changed the environment settings for your interactive project work this can lead to issues when running automated compilations. Make sure to deal with these accordingly in your automation scripts.
Traps to watch for
Care must be taken when replacing the text "BDS" in the exported file so that you don't change for example, the name of the executable from "bds.exe" to "MyConfig.exe".
The way I did this to simplify the process was to export the key, then I renamed the original key to MyConfig and then simply imported the untouched/unmodified exported key.