The last few days I have been playing around with a new Visual Studio 2005 feature called Project Item Templates and Project Templates found in Beta 1. Essentially it is a very cool way to create code and then have it show up inside of Visual Studio dialogs. For example, a “Project Item Template” shows up in the “Add New Item” dialog when you select the “Project” menu and choose “Add New Item”. A “Project Template” shows up in the “New Project” dialog when you select the “File” menu and choose “New Project”.
What is very cool is these templates are easily created and plugged into Visual Studio. Below is a basic way to get started with an Project Item Template.
Additionally, if you want the template to show up in the “Add New Item“ dialog with all the standard templates and not in the My Templates section, you can add the .zip file to the following location:C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\CSharp\1033
When performing this last step and placing the template with all the standard items it is important after you past the .zip file to the path above, you will need to run “devenv /setup“ from a command prompt, with Visual Studio not open. This is a bug in beta 1 that is being worked on.
I would love to hear any feedback that you have about this feature. Below is the sample code for the .vstemplate file that I discussed. For more information you can check out the online docs.-Jeremy
<VSTemplate Type="Item" Version="1.1.1"> <TemplateData> <Name> <String>Testing an Item Template</String> </Name> <Description> <String>A test of an item template</String> </Description> <Icon> <FilePath>Litening.ico</FilePath> </Icon> <ProjectType> <Languages> <Language>CSharp</Language> </Languages> </ProjectType> <DefaultName>Test.cs</DefaultName> </TemplateData> <TemplateContent> <ProjectItem> <SourceFile>Test.cs</SourceFile> </ProjectItem> </TemplateContent></VSTemplate>