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.
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.
Our Project Template
We are trying to create a project template which consists of 2 projects.
- Windows Application
- Class Library
The Windows Application will be referring to the class library.
Now use File -> Export Template as VSIX option.
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.
In the dialog box that appears, check both the projects as shown below and click the Next Button.
In the next page specify the template name and click the Next Button.
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.
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.
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.
Now restart Visual Studio and you will be able to see the Project Template listed as shown below:
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.
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.
The VSIX helps us by packaging all the project templates into a single VSIX file.
In this article we have used VSIX to create project templates.