Create Template Using VSIX in Visual Studio


In this article I would like to show the steps in creating a multiple project template inside Visual Studio. Visual Studio is one of the best Programming IDEs in the market and it provides vast amount of extensibility.

Using the Visual Studio VSIX Extension we can create project templates for our existing projects. In this way we can save a lot of time involved by reusing standardized projects.

Project Templates and Item Templates

Before proceeding, we should have a clear understanding of Project Template and Item Templates.

Project Templates represents the projects like Windows Applications, Class Libraries etc. Here more than one file is involved and the project file contains reference to all others. This template is added using the Add Project dialog.

img1.gif

The Item Templates usually will be a single file. Examples are Class file, Interface file etc. This template is added using the Add Item dialog.

img2.gif

Our Project Template

We are trying to create a project template which consists of 2 projects.

  1. Windows Application
  2. Class Library

The Windows Application will be referring to the class library.

Now use File -> Export Template as VSIX option.

img3.gif       

If you cannot find the above menu option, use the following link to download and install Export Template Wizard.  After installation you need to restart Visual Studio.

http://visualstudiogallery.msdn.microsoft.com/57320b20-34a2-42e4-b97e-e615c71aca24

In the dialog box that appears, check both the projects as shown below and click the Next Button.

img4.gif

In the next page specify the template name and click the Next Button.

img5.gif

You can change the Template name here.

The Icon Image input can be used to locate an icon for the VSIX. For time being leave it blank.

The Wizard Assembly input can be used to load an assembly file.  This assembly can contain custom code to change the default behavior of templates. 

Example

We can set the parameter values using Wizard Assembly.  This should be a signed assembly and raises deployment constraints.  For the time being we can set this to empty.

img6.gif

In the above page do the following modifications.

Set Product Name to MyCustomTemplate

Check the Automatically import..option

Now click the Finish button.  Your template will be created and opens in the explorer window as shown below.

img7.gif

Now restart Visual Studio and you will be able to see the Project Template listed as shown below:

img8.gif

Please note the group pane on the left side under which it is listed.

Deploying VSIX to User

We can send the above VSIX file to a user and on execution he will be prompted with the install dialog.

img9.gif

On clicking the Install button the template will be installed.The user machine should be having Visual Studio installed to handle the VSIX extension.

Note on VSIX file

A VSIX (Visual Studio Extension) file is a compressed file containing project templates. You can edit the extension .VSIX to .ZIP file to see the contents inside it.

img10.gif

The VSIX helps us by packaging all the project templates into a single VSIX file.

References

http://timheuer.com/blog/archive/2010/05/03/create-vsix-files-with-visual-studio-template-deployment.aspx
http://msdn.microsoft.com/en-us/library/ff363239.aspx
http://visualstudiogallery.msdn.microsoft.com/57320b20-34a2-42e4-b97e-e615c71aca24

Summary

In this article we have used VSIX to create project templates.

Up Next
    Ebook Download
    View all
    Learn
    View all