Introduction
I was looking for some solution that may be helpful in creating Code Templates to be used across the development team(s) and that can also maintain the versioning/revision history as well as provide integration with SourceSafe.
Background
After surfing The Code Project, I found Building VS .NET Wizards - Part 1 by Michael Groeger (thanks); this article helped me reach the solution for creating the templates. Still the idea was not complete. As I mentioned earlier, I wanted the solution to be integrated with SourceSafe to maintain versioning/revisions. I have gone through MSDN and found the working of SourceSafe with code and hence the Wizard Templates are attached.
Using the Code
The usage of these templates is really very easy and the two steps work as follows:
- Simply backup your folders from <VisualStudioDir>\VC#\VC#Wizards
- Copy the New Wizard folders to the above mentioned folder
You are done.
Open Visual Studio .NET 2003 and use any of the following Wizards; you will see the difference.
- CSharpAddClassWiz
- CSharpAddReportWebServiceWiz
- CSharpAddUserControlWiz
- CSharpAddWebFormWiz
- CSharpAddWebServiceWiz
- CSharpAddWinFormWiz
- CSharpAddWinServiceWiz
- CSharpClassWiz
- CSharpConsoleWiz
- CSharpWebServiceWiz
- CSharpWindowsServiceWiz
SourceSafe Integration
For SourceSafe configuration, follow the steps mentioned below.
You need to have SourceSafe configured at some machine accessible from your development machine. Use this article from the Microsoft Web site to learn more about how to configure SourceSafe to work with Versioning your code file.
Keyword Expansion
To integrate VSS with Visual Studio, you need to use Keyword Expansion. 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 |
VSS will add comments to your code at check in time if configured to do so in srcsafe.ini. This is useful because it shows a nice file history right in the file header and, if the comments are added during check in, describes the nature of each change.
Now to provide this functionality, you need to add the following lines to srcsafe.ini. (Please note that this file is located at the server where SourceSafe is configured.)
Keyword_Masks = *.cs, *.htm, *.html, *.aspx, *.ascx
;updates keywords in a user's working directory with the new keyword information
;when a user updates or checks in a file.
Expand_Keywords_Locally = YES
[Keyword Comments]
*.cs = " /// "
*.aspx = " -- "
*.ascx = " -- "
Now, you are done with SourceSafe integration.
History
I wanted to create an MSI to install this but could not spare time for this. Please provide me feedback after using the templates. Remember you can always modify the contents of the files as per your needs. Just a simple mail letting me know about you and your experience will be appreciated.
You can also discuss the article here.
History
- 14th August, 2005: Initial post