Friday, November 30, 2007

Create Templates for Visual Studio 2005

Create customized templates for Visual Studio 2003 and VS 2005 are very different. David Hayden has one blog on this issue with VS 2005.

It is very easy to create either a template project or template item in VS 2005. VS 2005 provides a wizard to do that from File|Export Templates... By the way, if you cannot find the Export menu item, you have to add it from Customize toolbar and drag the Export item under the File menu item.

However, I don't like to use the wizard to create or modify my template if I find some minor things to change or to create another one based on an existing one. I would like to work on copy-and-past pattern. The first thing I have to find out where my templates are and how they are organized.

For example, I created a template class item for NUnit test class. I want to create a similar one for MbUnit. I found out that after finished the wizard, my NUnit template is created under the following three locations (%userprofile% is "c:\Documents and Settings\[username]"):

%userprofile%\Application Data\Microsoft\VisualStudio\8.0\ItemTemplatesCache\NUnitTestClass.zip\
%userprofile%\My Documents\Visual Studio 2005\My Exported Templates\NUnitTestClass.zip
%userprofile%\My Documents\Visual Studio 2005\Templates\ItemTemplates\NUnitTestClass.zip

Actually, the template is saved at the third location. The first one is a cached template. If I want to change or create a new one, I have to go the last location to update or create one. After that, I copy and paste the new template to the second location.

It is much easier to update or create new template in this way.

By the way, I find one location in Google Code to host project files for downloading. I created my project site. I am going to put my source codes there. Here is list of my templates for NUnit and MbUnit test classes.

0 comments: