A reader emailed me this request for more infomation yesterday, “We keep several types of web projects in VSS, some apps from VStudio, some from dreamweaver, etc. As it stands now, both the shadow folder and deploy contain *all* the files. I'd like to be able to specify which files are (or are not) deployed.”

The current SourceSafe documentation does not address this common scenario very well. Argh.  I'll correct this as soon as I finish writing this blog post. The fix should be available in the next release of Visual SourceSafe.  If you're a seasoned VSS user who works with SS commands routinely and you have the attention span of a crack addict, here's the one line answer: SS GET $/projectname *.ext1 *.ext2 file?.* -GLc:\deploypath -Yusername (Italics == variables). For those of you who haven't been locked in a room with VSS and a box of donuts since 1996 and want to understand why and how this works (or even, what the heck it is), here's the full story.

You can “deploy“ the files in a VSS project to a physical location on your computer or another one on your network in three ways:

  • Set up a Shadow Folder for the database or for a specific VSS project folder (for more information about shadow folders, see related blog post #1 and blog post #2).
  • Designate a VSS project as a Web Project and then use the Deploy command.
  • Use the SS Get command-line command (Note: SS Checkout, which involves a Get operation, works as well).

As the reader who emailed this question points out, options 1 and 2 don't support per-file deployment. You can shadow a VSS project folder but you can't shadow an individual file.  You can Deploy the files in a VSS project folder to a path on disk but you can't use wildcards to specify exactly which files you want.

Option 3, SS Get, is the silver bullet.  You can use the SS Get command to retrieve an individual file to disk, recursively retrieve the contents of a VSS project or database to disk, or you can retrieve files with a certain extension or name pattern using wil*cards. The following procedure assumes that you have not configured your machine for turnkey execution of SourceSafe command-line commands.

  1. In Windows Environment Variables (My Computer|Properties|Advanced|Environment Variables) add variable SSDIR and set its value to the path of your database; the folder in which your srcsafe.ini file resides.
  2. Add a new environment variable PATH and set its value to the path to your \Win32 folder (e.g., %PATH%;c:\Program Files\Microsoft Visual Studio\vss\win32)
  3. Add a new environment variable SSUSER and set its value to your normal username (eg, RWagner).
  4. In Windows Explorer, browse to and open the \Users\your_username\ss.ini file in a text editor from your SourceSafe database directory.
  5. Add a new line: Force_Dir = Yes, and save your changes. (Note: this step is not mandatory for this particular operation but I strongly urge you to do this. For details, see Force_Dir, Get to Current Folder or Working Folder?.)
  6. Open a command shell and type: 
    SS GET $/projectname *.ext1 *.ext2  file?.* -GLc:\deploypath -Yusername
    where the variables ext1 and ext 2 are file extensions such as .asp, .aspx, .htm, etc, where file?.* is a filename that matches a certain pattern, and where username is your VSS login ID. Note: the first character of your file name cannot be ‘?’.
    The -GL switch allows you to override the default working folder and specify exactly where you want to place the files. If you completed step 5 and deploypath is the same as your working folder, the -GL switch is optional. If you completed step 3, the -Y switch is optional.

Result: Only files with the specified extensions and pattern-matching file names are "deployed" (aka, gotten) to the deploypath from your project.