The categories in the New Project and Add New Item dialog boxes reflect the directory structures that exist in the installed and custom template locations. You can modify these directory structures to organize your templates in a way that makes sense to you.
Note: |
|---|
You cannot create a new category at the programming language level. New categories can only be created within each language.
|
If the directory structures for installed and custom templates for a particular language do not have the same structure (that is, there are directories under one folder that do not exist under the other) the set of categories that appear in the New Project dialog will be the merger of all categories.
Organizing Installed Templates
You can organize installed templates by creating subdirectories within the programming language folder. These subdirectories appear as virtual folders in the New Project and Add New Item dialog boxes within each language.
To create new installed project template categories
Create a new folder in the language folder of the installed template directory. For example, to create an Office category for Visual Studio project templates you would create the following directory:
<VisualStudioInstallDir>\Common7\IDE\ProjectTemplates\VisualBasic\Office
Place all the templates for this category in the new folder.
Close all instances of Visual Studio.
On the Start menu, click Run, type "cmd", and click OK.
At the command prompt, navigate to the directory that contains devenv.exe, and type "devenv /setup".
Run Visual Studio.
On the File menu, click New, and then click Project.
Verify that the Office category appears under Visual Basic in the Project types pane in the New Project dialog box.
Similarly, you can group a subset of the project item templates into a custom folder.
To create new installed item template categories
Create a new folder in the language folder of the installed template directory. For example, to create a Web category for Visual C# item templates you would create the following directory:
<VisualStudioInstallDir>\Common7\IDE\ItemTemplates\CSharp\Web\
Place all templates for this category in the new folder.
Close all instances of Visual Studio.
On the Start menu, click Run, type "cmd", and click OK.
At the command prompt, navigate to the directory that contains devenv.exe, and type "devenv /setup".
Run Visual Studio.
Create a new project or open an existing project.
On the Project menu, click Add New Item.
Verify that the Web category appears in the Project types pane in the Add New Item dialog box.
Organizing Custom Templates
Custom templates can be organized into their own categories by adding new folders in the custom template location. The New Project dialog box reflects any changes you make to your template categories.
To create new custom project template categories
Create a new folder in the language folder in the custom project template directory. For example, to create a HelloWorld category for Visual C# templates you would create the following directory:
My Documents\Visual Studio 2008\Templates\ProjectTemplates\CSharp\HelloWorld\
Place all the templates for this category in the new folder.
On the File menu, click New, and then click Project.
Verify that the HelloWorld category appears under Visual C# in the Project types pane in the New Project dialog box.
Similarly, you can group a subset of the custom item templates into a custom folder.
To create new custom item template categories
Create a new folder in the language folder in the custom item template directory. For example, to create a HelloWorld category for Visual C# templates you would create the following directory:
My Documents\Visual Studio 2008\Templates\ItemTemplates\CSharp\HelloWorld\
Place all the templates for this category in the new folder.
Create a new project or open an existing project.
On the Project menu, click Add New Item.
Verify that the HelloWorld category appears in the Project types pane in the Add New Item dialog box.
Displaying Templates in Parent Categories
You can allow templates in subcategories to be displayed in their parent categories by using the NumberOfParentCategoriesToRollUp element in the .vstemplate file. This procedure is identical for both project and item templates.
To display templates in parent categories
Locate the .zip file that contains the template.
Extract the .zip file.
Open the .vstemplate file in Visual Studio.
In the TemplateData element, add a NumberOfParentCategoriesToRollUp element. For example, the following code makes the template visible in the parent category, but no higher:
|
<TemplateData>
...
<NumberOfParentCategoriesToRollUp>
1
</NumberOfParentCategoriesToRollUp>
...
</TemplateData> |
Save and close the .vstemplate file.
Select the files included in your template, right-click, select Send To, and click Compressed (zipped) Folder. The files that you selected are compressed into a .zip file.
Delete the extracted template files and the old template .zip file.
Place the new .zip file in the same directory as the deleted .zip file.