Saturday, 25 August 2012

Project Template Locations in VS2012

Adding a Project Template 

If you've seen my post on creating a console application in VS Express 2012 for Web, you'll be thinking "why doesn't he create a template?" Well I did, via the Export Template Wizard in visual studio (File -> Export Template...)

This wizard creates a zip file of all the items in the current project. When this is copied to the correct location on your machine, it can be used to create a new project with all your previous goodness. The location to copy it to is [Visual Studio 2012 folder]\Templates\ProjectTemplates\Visual C# or[Visual Studio 2012 folder]\Templates\ProjectTemplates\Visual Basic

This allows you to select your template in the New Project dialog box

Specifying the Project Type

If you want the template to appear under one of the project types, e.g. Windows, put the .zip file into a directory of that name, e.g. [Visual Studio 2012 folder]\Templates\ProjectTemplates\Visual C#\Windows

Can I Have it in Both?

If you want it in both locations, Visual C# and Windows, you need to edit your template. Open the .zip file and there'll be a .vstemplate file; this is the definition of the project template. You need to add an element NumberOfParentCategoriesToRollUp. This tells VS to show the template in the project subtype (Windows) and its parent (Visual C#). Here's an example:

No comments:

Post a Comment