This documentation is archived and is not being maintained.

How to: Add Templates to the New Project Dialog Box

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

A number of predefined project templates are installed during Visual Studio installation. For a complete list of predefined project templates, see Default Project Templates in Visual Studio. In addition to default project templates you can create custom or subtype-specific project templates. For example, the Smart Device subtype provides its own templates for Visual C# and Visual Basic projects. For instructions on how to create a custom template, see How to: Create Project Templates. In order to create a new project based on your custom template you need to add a custom template to the Visual Studio New Project dialog box. The template is added to the Project Types list in Other Languages node of the New Project dialog box. The icon associated with this new template is placed within Visual Studio Installed Templates, located in the Templates pane of the New Project dialog box.

Adding a Template to the New Project Dialog Box

To add a template to the New Project dialog box

  1. Provide a project factory for your project subtype.

    public class ProjectFactory : FlavoredProjectFactory
        private ProjectSubtype package;
        public ProjectFactory(ProjectSubtype package)
            : base()
            this.package = package;
  2. Register your project with Visual Studio by using the ProvideProjectFactoryAttribute class.

    [MSVSIP.ProvideProjectFactory(typeof(ProjectFactory), "Task Project", "Task Project Files (*.csproj);*.csproj", "csproj", "csproj", "..\\..\\Templates\\Projects")]
    public sealed class ProjectSubtype : MSVSIP.Package


    typeof(ProjectFactory) is the type of factory the VSPackage offers,

    "Task Project" is the name of the project and the name of the template,

    "Task Project Files (*.csproj);*.csproj" is the resource ID of the display string representing the project file extensions,

    "csproj" is the default project extension,

    "csproj" is the project extension supported by this project factory,

    "..\\..\\Templates\\Projects" is the directory containing the templates of this project factory.

  3. Instantiate and register your project factory with Visual Studio in Initialize() method of the VSPackage.

    protected override void Initialize()
        // Create and register your project factory.
        this.RegisterProjectFactory(new ProjectFactory(this));

Note   This code example is part of a larger example provided in Project Subtype Sample.

See Also