January 27, 2021
Hot Topics:

Completing the NUnit Project Template for .NET, Part 2

  • By Paul Kimmel
  • Send Email »
  • More Articles »

Define the Wizard Launch File

A wizard launching file is a text file with a .vsz extension. Each wizard launching file indicates the wizard class that is used to create a project from the template and parameters to that class. To create our wizard launching file, copy the Class Library's wizard launching file and rename the copy TestClassLibrary.vsz. In a default VS.NET installation, the location of these files will be c:\program files\microsoft visual studio .net 2003\vb7\vbprojects, and the contents of our wizard launching file are shown in Listing 3.

Listing 3: The TestClassLibrary.vsz wizard launching file.

Param="WIZARD_NAME  = TestClassLibrary"
Param="WIZARD_UI    = FALSE"

Define the VSDir File Entry

Technically, we have worked backward in implementing the project template solution. The first thing the vswizard.dll does is look in a specific location for a file with a .vsdir extension. The .vsdir file is used to tell the wizard where the wizard launching file is, which in turn indicates the location of the template files and scripts, and so on.

In a default VS.NET installation, the .vsdir file we need to modify is located at c:\program files\microsoft visual studio .net 2003\vb7\vbprojects\projects.vsdir. This file is a text file that contains information that describes how to display the project item template in VS.NET. Because our TestClassLibrary is very similar to the ClassLibrary, we can copy the ClassLibrary's .vsdir entry and make a few changes for our new template project. Listing 4 contains our .vsdir entry. It is important to use just one line when you add this entry although multiple lines are used here due to limited page real estate.

Listing 4: The VSDir entry for the TestClassLibrary.

                    |NUnit Test Library|20|#3001

The .vsdir entries are delimited by the pipe (|) symbol. Table 1 describes each of the .vsdir fields.

TestClassLibrary.vsz Relative path and file name of the wizard launching file
{164B10B9-B200-11D0-8C61-00A0C91E29D5} The CLSI for the VB Editor Factory
NUnit Test Library A new or resource id for the name of the template
20 The sort priority
#3001 A localized resource string
{164B10B9-B200-11D0-8C61-00A0C91E29D5} The CSLID or path for template icons
4500 Icon resource ID (we'll be using the same icon as the Class Library's icon)
<blank> Flags
TestClassLibrary The suggested base name for new projects

Testing the Wizard

After we modify the .vsdir file, we are ready to test our new project template. To test the project template, select File|Add New Project. Assuming the .vsdir file is prepared correctly, we will see the NUnit Test Library icon in the Add New Project dialog (see Figure 1). Select the template icon and a complete test library project should be created. If we completed all of the other steps correctly, the new project should compile and load in NUnit without modification.

Click here for a larger image.

Figure 1: Our new project template in VS.NET's Add New Project dialog.

Each time you want to create a new test library, you can use the new project template and add tests to it after the project is created. Over a period of weeks and months, this one template should save you many hours of writing repetitive code.


Have you ever heard of the notion of hyper-productive programmers? A hyper-productive programmer is someone who writes as much as ten or twenty times more code than their peers. How does this happen, you might ask? The answer is that hyper-productive programmers take short cuts, use code generators, and have a rhyme and reason for the things they do. Shortcuts, macros, code generators, and habits guide a hyper-productive programmer's actions.

Perhaps you strive to be a hyper-productive programmer or you already are. Either way, using project or item templates will result in code that is pre-written, always correct, and will increase your productivity.

About the Author

Paul Kimmel is the VB Today columnist for codeguru.com and developer.com and has written several books on object-oriented programming, including the recently released Visual Basic .NET Power Coding from Addison-Wesley and the upcoming Excel VBA 2003: Programmer's Reference from Wrox Press. He is the chief architect for Software Conceptions and is available to help design and build your next application.

The Lansing, Michigan area has started a new .NET Users Group. A well-run group offers great learning and networking opportunities and occasionally some free pizza and door prizes. Contact me at pkimmel@softconcepts.com if you live in mid-Michigan and are interested in participating.

# # #

Page 2 of 2

This article was originally published on April 27, 2004

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date