Export (0) Print
Expand All
1 out of 2 rated this helpful - Rate this topic

Adding Custom Folders for Enterprise Template Projects to Visual Studio .NET Dialog Boxes

Visual Studio .NET 2003
 

Steven Powell
Visual Studio Team
Microsoft Corporation

February 2002

Summary: Describes how to create top-level folders in various Visual Studio .NET dialog boxes for easy access to Enterprise Template projects. Readers should be familiar with Visual Studio .NET and Enterprise Templates. (5 printed pages)

Contents

Introduction
Adding Custom Folders to the New Project and Add New Project Dialog Boxes
Adding Custom Folders to the Add New Item Dialog Box

Introduction

If you use Visual Studio® .NET Enterprise Templates to create policy-guided templates, language projects, or project items, you can make them easily accessible in custom folders in several Visual Studio dialog boxes. You can provide a top-level custom folder to your development team in the New Project, Add New Project, and Add New Item dialog boxes. The process for adding a custom folder is similar for the New Project and Add New Project dialog boxes. Adding a custom folder to the Add New Item dialog box requires a slightly different process. This article describes how to add custom folders to all three dialog boxes.

Adding Custom Folders to the New Project and Add New Project Dialog Boxes

When creating new templates or new language projects with policy, you can provide a new top-level folder, rather than having them reside under the Other Projects \ Enterprise Template Projects folder in the New Project or Add New Project dialog boxes. For example, if you create a set of custom templates for your development team, it might be helpful to have a custom folder available alongside the Visual Basic, Visual C#, and Visual C++ folders. To create a new top-level folder and have custom templates or projects reside in that folder, follow the steps described in detail below.

There are two parts to this process:

  • Generate a unique GUID.
  • Update the registry using the GUID to point to your custom template directory.

For the first part, you can use a tool such as GUIDGEN to generate a unique GUID in registry format. For example, assume you run GUIDGEN and receive the unique GUID: {499D9F32-1BA6-4a5e-A781-188CAF8085FE}.

For the next part, you need to modify the registry.

To modify the registry for the New Project dialog box

  1. Run RegEdit and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\NewProjectTemplates\TemplateDirs.
  2. In the TemplateDirs node, add a key where the key name is the GUID generated above.
  3. Beneath the GUID-named node, add a node named "/1", with a (Default) value equal to the name you want to appear in the New Project and Add New Project dialog boxes for this folder. For example, name the folder "TopLevelFolder".
  4. Add two more sub-keys to the "/1" node.
    1. Make the first key a DWORD key named "SortPriority". The value determines in what order the folders appear in the dialog boxes. A smaller number corresponds to a higher rank. Assume you want your custom folder to always appear first, so give it a SortPriority of "0".
    2. The second key is a string key named "TemplatesDir" and the value is the path to your custom projects folder. For this example, your custom projects appear in the folder "D:\Public\Demo\EnterpriseFrameworks\ProxyProjects". If you have a set of templates that reside on a network share, you can put the UNC path here.

The registry tree should look similar to this:

Figure 1. Registry tree

The keys and values for the "/1" node should appear similar to this:

Figure 2. Registry keys and values

Note   There are a few limitations. If your custom template launches sub-project wizards, those wizards must reside in the [Drive letter where Visual Studio .NET is installed]:\Program Files\Microsoft Visual Studio .NET\EnterpriseFrameworks\EFWizards folder, regardless of where the template itself is located. Similarly, if your template only specifies the name of the policy file and not the full path, then that policy file needs to reside in the standard policy folder (EnterpriseFrameworks\Policy) in order to be found. If your template uses static prototypes and contains an absolute path to the policy file, then all of your template files can reside on a network path.

To see your changes, shut down and restart Visual Studio if it was running when you made the registry changes. When you launch the Visual Studio .NET IDE, the New Project dialog box now appears as follows:

Figure 3. New Project dialog box with custom folder

The preceding steps add your custom folder to the New Project dialog box, which makes your folder available only when a user creates a new project. However, if a user adds a project to a parent Enterprise Template project, they use a customized version of the New Project dialog box, named the Add New Project dialog box. You need to make a second registry entry to modify this dialog box.

To modify the registry for the Add New Project dialog box

  1. Within RegEdit, navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\Projects\{FE3BBBB6-72D5-11d2-9ACE-00C04F79A2A4}\AddItemTemplates\TemplateDirs.
  2. In the TemplateDirs node, add a key where the key name is the GUID generated above.
  3. Beneath the GUID-named node, add a node named "/1", with a (Default) value equal to the name you want to have appear in the New Project and Add New Project dialog box for this folder. For this example, name the folder "TopLevelFolder".
  4. Add two more sub-keys to the "/1" node.
    1. Make the first key a DWORD key named "SortPriority". Assume you want your custom folder to always appear first, so give it a SortPriority of "0".
    2. The second key is a string key named "TemplatesDir" and the value is the path to your custom projects folder. For this example, your custom projects appear in the folder "D:\Public\Demo\EnterpriseFrameworks\ProxyProjects". If you have a set of templates that reside on a network share, you can put the UNC path here.

Adding Custom Folders to the Add New Item Dialog Box

In addition to adding a new top-level folder to the New Project and Add New Project dialog boxes, you might also want to add a new folder in the Add New Item dialog box. The primary difference is that this dialog box is always language-specific, so you need to add the folder to the appropriate location for the language of your custom project item. The process for adding a custom folder to the Add New Item dialog box is much easier than adding a folder to the New Project or Add New Project dialog boxes and does not require registry editing.

The steps required are as follows:

  • Locate the project items folder in the language desired.
  • Add a .vsdir file that points to the custom folder you created.
    -or-
    Simply create the subfolder beneath the project items folder.
  • Put the new items in the folder you created.

Locating the Project Items folders

A ProjectItems folder appears in the language installation folder. The default installation locations are as follows:

Language ProjectItems Folder Location
Microsoft® Visual C++® C:\Program Files\Microsoft Visual Studio .NET\Vc7\vcprojectitems
Microsoft® Visual C#™ C:\Program Files\ Microsoft Visual Studio .NET\VC#\CSharpProjectItems
Microsoft® Visual Basic® C:\Program Files\ Microsoft Visual Studio .NET\Vb7\VBProjectItems
Note   You are not required to install Visual C++ under the Microsoft Visual Studio .NET folder. If the Visual C++ ProjectItems folder is not in the Visual Studio .NET\Vc7 installation folder, then you can find it in the folder where you installed Visual C++.

Creating Your Custom Folder

There are two approaches to adding your custom folder to the Add New Item dialog box. You can add a .vsdir file that points to your custom folder or you can create your subfolder directly in the ProjectItems folder.

If you create a .vsdir file that points to a folder elsewhere, the syntax in the.vsdir file must be in one of the following formats.

Option 1:   FolderPath|PackageGUID|StringResourceID|SortOrder

Option 2:   FolderPath|FolderName|SortOrder

Option 1 points to a package GUID and string resource ID. This allows you to have localizable folder names in the Add New Item dialog box. Option 2 is much simpler if you do not need to localize your names and simply specifies the folder name. In either case, you also specify the folder path and a sort order. The folder path is either a relative or absolute path to the folder containing your custom project items. The sort order controls the order in which folders are displayed in the Add New Item dialog box.

You can also opt for maximum simplicity, if you want your project items to live in the same folder where the standard project items reside. You do not need to create the .vsdir file that points to your folder, but can simply create the folder in the appropriate language ProjectItems parent folder. In the new sub-folder add the .vsdir files that point to your custom project items within that subfolder.

Add New Items

After creating your folder, add to it the items that you want to make available to users in the Add New Item dialog box.

To see your changes, shut down and restart Visual Studio.

For an example, see the "Creating a Project Item Prototype" section in Walkthrough: Creating a New Enterprise Template Building Block in the Visual Studio .NET documentation.

For more information on Enterprise Templates, see Enterprise Templates for Distributed Applications in the Visual Studio .NET documentation.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.