Jason Mauss' Blog Cabin

Because someone's got to do the dirty work

Blog-Flair

Blogroll

Links

VSS Tips & Tricks

For most Microsoft development teams, Visual Source Safe (VSS) is chosen as the Source Code Management tool before alternatives (like Vault or CVS) are even compared. What this means is that if you work on one of these teams and you’re managing concurrent development, you’ll likely be doing so with the help of VSS. It’s also fair to say that most developers or de-facto VSS administrators don’t ever get a minute worth of training on how to use the features provided by VSS let alone how VSS works behind the scenes. In this article I will show you how to use VSS to automate certain processes and discuss how to use features you might not know exist.

 

Love it or hate it but, as Microsoft developers you’ve all probably used Visual Source Safe at some point. Most simply use it as a check-in and check-out code library to manage concurrent development. With so many developers using VSS, you might think you would see it improved and modernized as it is integrated with newer releases of Visual Studio but alas, this is not the case. By simply looking at the technologies VSS implements, we can easily see it is behind the times. INI files instead of XML Configuration files, poor performance over remote connections, and less than stable integration with the VB6 IDE, just to name a few. Even some teams at Microsoft use a homegrown command line tool called “Source Depot” instead of VSS. Having said that, there are plenty of things that VSS does do well, such as:

 

  • Branching
  • Labeling
  • Check In and Check Out
  • Cloaking
  • Sharing

 

In addition to these standard features, there are tweaks you can perform to increase performance, automate keyword expansion, validate html links, and even have VSS generate a site map for your web projects.

 

The Invisible Login

Using the VSS Admin tool, you can turn on the option for your developers to “Use network name for automatic user login” but, if you decide that you want VSS logins separate from network logins, you’re going to be required to login each time you run the VSS Explorer. If you’re the type of person that likes to keep entering login credentials to a minimum, this feature is for you. By using environment variables, you can specify your VSS login (and optionally, your password) without having to type it each time you run the VSS Explorer. To do this, you simply create an environment variable named SSUSER and store your VSS login name in the value. If you choose to, you can do the same thing, using SSPWD to store your password. If you’re concerned about the security of these environment variables (which you should be) then be sure to create these as User Environment Variables, rather than System Environment Variables. This allows Windows to protect these values and only give access to them when the specific user they pertain to is logged in. Also, it is recommended that you do not store your password in SSPWD under Windows 95. Figure 1 shows the environment variables after they have been set.

 

Figure1. User Environment Variables dialog.

 

Using environment variables doesn’t stop there. Setting SSUSER gets you around needing to specify a login, but what about specifying the VSS Database you want to connect to? If the database you need to connect to is on a share (which is most often the case among teams of developers) then you can configure an environment variable named SSDIR to contain the path to the VSS database (the srcsafe.ini file).

 

Gotcha #1: For those of you using Visual Studio.NET, you might experience problems using the environment variables. To solve this with Visual Studio.NET, go to Tools | Options | Source Control | SCC Provider to find options for setting the default login to be used.

 

Gotcha #2: If you decide to go with using the network name to allow users to be logged in automatically, make sure you use the VSS Admin tool to make each user’s VSS password blank. Since VSS doesn’t use the same password as the NT User, you need a blank password for this to work.

 

Take Advantage of Keywords

Keyword Expansion refers to the ability VSS has to replace certain sections of files with information relevant to the file such as the last time it was modified, who modified it or the date and time the last check in operation occurred. Typically, you will want to place the keywords in commented sections of code at the top of your source files so they do not affect compilation. Here is a quick table of all the VSS keywords and what information they provide.

 

Note: Keywords are case-sensitive so be sure to capitalize them properly.

Keyword

Information Provided

$Archive: $

VSS archive file location

$Author: $

User who last changed the file

$Date: $

Date and time of last check in

$Header: $

Logfile, Revision, Date, Author

$History: $

File history, VSS format

$JustDate: $

Date, without the time addendum

$Log: $

File history, RCS format

$Logfile: $

Same as Archive

$Modtime: $

Date and time of last modification

$Revision: $

VSS version number

$Workfile: $

File name

$NoKeywords: $

No keyword expansion for all keywords that follow

 

For example, if you added the following to a C# source file:

//VSS Keyword information

//File last modified by: $Author: $

//on $Date: $

 

VSS would replace it with

 

//VSS Keyword information

//File last modified by: $Author: Jason Mauss $

//on $Date: 06/28/2003 10:30:15 AM $

 

As you can see, this takes the pain out of keeping track of who has done what and when. If you would like to format the keyword data into nice blocks of information you can also use the double colon format which looks like:

 

$Date::        $

 

or

 

$History::     $

 

This tells VSS that you want the dollar sign (the end of the line) exactly at that position, and it will align or truncate the information so they you can create more readable columnar information.

 

Keyword expansion can also come in handy with web files (html, asp, jsp, etc.). Using the JustDate keyword, you could automate modifying the text in a page footer that tells the last time the page was modified. For example, you could place the following in a file:

 

This page last modified on <!--$$JustDate:--!> <!--$-->

 

And upon check in, VSS would replace that text with

 

This page last modified on <!--$$JustDate:--!>6/28/03<!--$-->

 

And upon each subsequent check in, the file would be updated with the current date. For those of you wondering if you can create your own custom keywords for expansion, unfortunately it is not supported in the latest version of VSS.

 

Tips for Web Projects

For web developers using VSS to maintain their various web files, a few features specific to web projects are available. These are Check Hyperlinks, Create Site Map, and deploy. All of these features can be found under the “Web” menu in VSS Explorer.

 

The Check Hyperlinks features does exactly what it sounds like it does. For all the files in your web projects that contain an anchor tag with an href attribute “<a href=www.mysite.com>mysite</a>” VSS will validate the links. It can also check links external to your web project on the web. After checking all the links, VSS will display a dialog telling you which files had errors, links that seem to be invalid, and links found but, not checked. This features comes in handy when you are ready to deploy your web files to a web server or have had your site running for some time and want to check for stale or expired links in your HTML.

 

The Create Site Map feature allows you to use VSS to generate an HTML file that contains links to pages in your web project. The page generated by VSS is fairly crude but, it can save you some time collecting links to all your pages.

 

The Deploy feature allows you to copy your files to a folder or FTP location that is configured on a per-project basis before the deploy command is used. This allows you a quick and easy way to copy the new changes to web files to a live web server. When using this feature be sure that all developers have write permissions to the folder or access to FTP is configured properly on your network.

 

Best Practices for VSS Administrators

Sometimes ease of use can be misleading. For example, VSS is pretty easy to install and it’s very simple to set up a VSS database. What you should know though, is that VSS is not optimized for performance out of the box. Here are some things you should be aware of so that you can get better performance out of VSS.

 

1. In the ss.ini or the srcsafe.ini file (the VSS database) set the Diff_Ignore (PC) value to c-e-s-w which will tell VSS not to ignore end-of-line differences, which will speed up file comparisons.

 

2. Set the CP_OnSelection value to NO.  This is incredibly useful for users accessing VSS over a remote connection. Why? Normally whenever you click on a folder (a project or project grouping level) VSS performs a selection operation, which can take a while over a slow remote connection. By setting CP_OnSelection to no, users can drill down in the project hierarchy and just double-click or hit Enter when they find the folder they want to actually select, not having to wait a while for each level they expand.

 

3. Set the path of your temporary folder to a local temp folder (like C:\Windows\Temp) in your SS.INI file. This will have VSS write temporary files locally instead of perhaps to a network drive.

 

4. Know which features you need and disable ones you don’t. Here are 4 features that are costly that should be disabled if not needed:

 

  • Shadow Folders
  • Journal Files
  • Project Security System
  • Keyword Expansion

 

5.  Run the Analyze.exe utility against your VSS database about once a week to ensure the integrity of the database. Analyze.exe will scan the VSS database for errors and fix them if possible. Find these errors and fix them before your developers come across them. You could even create a batch script and schedule a job that runs Analyze.exe at a regularly scheduled interval.

 

Note: Make sure all users are logged out of VSS before running Analyze.exe. Files can be checked out however, during this process.

 

6. Use the SSARC.exe utility regularly to archive and compress part or all of your VSS database for backups. Using SSARC.exe will reduce the amount of space required to backup your VSS database. This is most important for large scale users of VSS, who likely have more than one database.

 

Conclusion

As you can see, there is a lot you can do with VSS, if you know what’s there and how to use it. If you manage a team of developers I urge you to put them through some kind of training so they don’t have to learn how to use VSS and its features the hard way.  Taking time to configure VSS properly can also help you tighten your development cycle in terms of managing the build process and web application deployment. With a little planning up front, you can save yourself headaches later on.

Comments

Darrell said:

Oh, and my comment wasn't to say you didn't write an excellent blog post!
# September 17, 2004 10:51 AM

Parag Shah said:

is it possible to have VSS userid / password to be directly sign in with my network credentials so that once i log on to machine with my id, it should use same userid/password.

# July 13, 2008 6:39 AM

Awais Usman said:

very helpful. thanks

# October 13, 2008 12:24 AM

Antony said:

The hyperlinks in WORD and EXCEL stored in VSS dont work. Any remedy?

# October 28, 2008 5:34 PM

Dave Townsend said:

Thank you. It was very helpful

# November 4, 2008 2:28 AM

Saikat said:

Great help! i was tired sick of entering the user credentials each time of login!! Your tip saved me some fustration :-D

# November 5, 2008 4:42 AM

S Jain said:

The keywords expansion in WORD and EXCEL stored in VSS are not working. Any remedy?

Thanks in Advance.

# December 2, 2008 1:05 AM

Ram said:

when i tried to create a new project under the VSS root folder am getting the following error and i couldn't crete any new folders even i have Admin rights.

i am getting the follwing error.

" File c:\vss\data\a\aaaaaaaa is already open" please help how to solve this problem.

# December 3, 2008 4:28 AM

Kurt Redling said:

In our .Net solution I have added $History: $ and $Log: $ to our source files (actually I am testing it with just a couple of files first).  We have both *.vb (VB.NET) and *.cs (C#) files in the solution.  I added the Key Words to both a C# file and a VB.NET file.  After checking in I can view the file in Source Safe and the C# file expands the Key Words as expected, but the VB.NET file did not expand them.  The same goes when I try to view the file with Visual Studio.

In my srcsafe.ini file . . .

Keyword_Masks = *.vb, *.cs

[Keyword Comments]

*.vb = "' "

*.cs = "// "

Any idea what I did wrong for the VB.NET files?

Thanks in advance,

Kurt

# December 9, 2008 4:18 PM

Kurt Redling said:

Forget my last posting.  I figured it out.

Thanks!

# December 9, 2008 9:40 PM

Michael said:

I too get the "file ... already open" error message, when trying to create a project (folder) within a project (folder).  Does anyone have a solution to this?

# November 4, 2009 7:09 PM

Phil Pinkerton said:

Can VSS Archive be ran via the command line ? What migtht that look like (syntax) ?

# December 21, 2009 9:07 AM

Arun said:

Is it Possible to check in the files which user has left checked out and left the organization. The user Id has been disabled/Deleted. Please advice.

# February 25, 2010 7:20 AM

Anonymous said:

Guys this article has been closed now, so no more comments please. Create a separate thread if you need further assistance.

# July 30, 2010 6:48 AM

Nita said:

We are using VSS 2005 n had not done with Credential Login for newly created database. can u plz tell steps for assigning username and password for Admin, Guest and Administrator.

# August 26, 2010 1:15 AM

Nita said:

Is it necessary to have a System's username & password same for VSS 2005 s/w? or by default, VSS takes system's username. and then we can change only password.

# August 26, 2010 2:44 AM

ipad2 cases said:

Youre so right. Im there with you. Your weblog is definitely worth a read if anyone comes throughout it. Im lucky I did because now Ive obtained a whole new view of this. I didnt realise that this issue was so important and so universal. You certainly put it in perspective for me.

# May 28, 2011 7:53 AM

weblogs.asp.net said:

Vsstipsntricks.. Neat :)

# May 30, 2011 6:04 PM

Custom Software and Web Development said:

Hi.... thanks for sharing so meaningful information with us. thanks a lot. i was searching for this type of information to gain knowledge. thanks a lot

# August 12, 2011 4:23 AM

ecommerce website development said:

Thanks for this useful post..Really too interesting and informative information is shared.

# April 23, 2012 2:57 AM

Copley said:

I don't even know how I ended up here, but I thought this post was good. I don't know who you are but definitely you are going to a famous blogger if you aren't already ;) Cheers!

# July 11, 2012 9:01 AM

Arndt said:

banners on their sites, may well almost seem foolish to not ever join.

# December 26, 2012 10:17 PM

Jack Phillips said:

Are you aware of a way to kick out all of the source files for a Project at a given label into one file...For copyright submission purposes?

Regards,

phillipsj@datascapesystems.com

Jack

# January 7, 2013 11:49 AM

vss user said:

awesome .. i never knew vss could do such things .. thanks a lot whoever u are

# January 23, 2013 5:26 AM

Handley said:

Its not my first time to visit this web page, i am visiting this

site dailly and get good data from here everyday.

# January 24, 2013 6:32 AM

Wells said:

Great article! We will be linking to this particularly great

content on our site. Keep up the good writing.

# February 14, 2013 12:10 AM

Kenny said:

But involve for places far to have a less epicurean Vacation if it is too cheaper.

Yoke was 29 when her breakthrough albumThe cleaning lady in Mewas released in

the Springiness of 1995, then 31 whenCome On Overcame out in old age later another

Dublin man died in the same online pokies.

# February 16, 2013 9:18 PM

Clarkson said:

One of those michael zimmerman prentice owners is

Robert Jaffe of rampart Street is that you Ne'er add to a losing position.

# March 1, 2013 7:27 AM

Donald said:

Hi there, this weekend is fastidious in favor of me, as this occasion i am reading this

fantastic educational post here at my residence.

# March 7, 2013 5:45 AM

Stroup said:

Hi there, after reading this remarkable piece of writing i am too happy to share my experience here with mates.

# March 19, 2013 3:51 AM

vss user said:

I have a query on VSS .. if i can do some magic with ss.ini to ignore labels being listed in history for a specific user . can this be done ? I badly need some help !!

# March 26, 2013 8:11 AM

vss user said:

a query .. is there any property in ss.ini to ignore labels being listed in history for a specific user .. i badly need help !!  

# March 26, 2013 8:13 AM

Crespo said:

Hello mates, how is everything, and what you wish for to say concerning this paragraph, in my view its in fact

awesome designed for me.

# May 15, 2013 10:55 PM