How to: Programmatically Create Projects

Visual Studio add-ins are deprecated in Visual Studio 2013. You should upgrade your add-ins to VSPackage extensions. For more information about upgrading, see FAQ: Converting Add-ins to VSPackage Extensions.

To create a project, call GetProjectTemplate, and then pass the returned template paths to AddFromTemplate.

Project templates have a .vstemplate file name extension and are stored in .zip files. To obtain the path of the .vstemplate file (in the .zip file), use GetProjectTemplate, and then pass it to AddFromTemplate to create the project (and also a solution, if one is not already open). You can perform this operation as many times as required, and every project will be added to the currently open solution.

The project templates for all languages can be found in Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\Language\.

You can also create your own custom project templates. To specify the directory in which you will store your templates, click Options on the Tools menu. In the left pane of the Options dialog box, click Projects and Solutions. Type the path of your templates in the Visual Studio user project templates location box.

Custom project templates require unique file names that do not conflict with the file names that are defined in Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\Language\.

Ensure that you use long file names (as opposed to 8dot3). For more information, see Creating Project and Item Templates.

Note Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. These procedures were developed with the General Development Settings active. To change your settings, click Import and Export Settings on the Tools menu. For more information, see Customizing Development Settings in Visual Studio.

To programmatically create a project

  1. Start Visual Studio and create a Visual Studio add-in project.

  2. To the add-in Connect class, add the example code shown later in this topic.

  3. Run the add-in project and activate it in Add-In Manager.

    To do this, click Add-In Manager on the Tools menu and then select the add-in.

The following example uses GetProjectTemplate and AddFromTemplate to create two console projects, one Visual Basic and the other Visual C#, in a solution.

No code example is currently available or this language may not be supported.
Show: