views:

239

answers:

2

I have a a project that resides on a "thumb drive" (a.k.a. memory stick). Due to Windows ability to change drive letters of thumb drives, I would like to specify the location of sub-projects using an environment variable. This allows me to set the thumb drive drive letter, depending on the PC that I am using; or change the variable when the drive letter changes (such as happens when adding a hard drive to the PC).

This issue has sub parts:

  1. How do I tell Visual Studio (2008) to use environment variable when adding an existing project using the GUI?

  2. Which files do I need to modify with the environment variable (*.dcp, *.vcproj, *.sln)?

  3. Do I need to delete the platform specific vcproj files, such as *.vcproj.*host_name*?
    {Since I use different host PCs with the thumb drive, there are different vcproj files.}

I am using MS Visual Studio 2008, C++, on Vista and Windows XP (at least two platforms).

A: 

You can also overcome the wandering drivename by using the 'subst' command.

for instance

f(thumbdrive):\>  subst z: projectfolder

and then you can always access your folder at z:\, presuming none of the computers have a 'z:' drive installed.

Stef
Although I have not tested this, I know that on Windows XP, adding a hard drive will bump up drive letters and without any concern to network drive mappings. If I have a network share at "D:" and I add a hard drive, the hard drive becomes "D:" *AND* my network share is still mapped to "D:". My understanding is the `subst` is along the same lines as mapping a network drive.
Thomas Matthews
A: 

The best solution here is to use relative paths for your subprojects. The relative path from your solution file to the subprojects does not change, as both are on the same thumb drive.

MSalters
If this is the best solution, how do I make the GUI "Add Existing Projects" using relative addressing? Also, where is the "point of reference" for relative addressing?
Thomas Matthews