How to create a Visual studio 2013 project template

Recently at work we had to create a lot of microservices where we required to copy-paste lot of files from one sample solution to the specific service implementations. The necessity of this approach comes from the many small differences between each service.

Of course the common code was extracted to shared libraries but this was just a partial solution. Now that we can grasp their usefulness, let’s see how to create visual studio templates!

Different options for creating templates
There are three ways to create a project template:

  1. Exporting a template from an existing project
  2. Creating a template project
  3. Exporting an existing project then copying its content to a template project

In this tutorial we will explore the first option.

Exporting a template from an existing project
1. Create a new project or open an existing one. For this tutorial we will use an incredibly simple web crawler console project.
Exmple project for template creation

2. Open the File menu, and click on the Export Template… option.
Export Visual Studio 2013 Project template

3. Make sure the Project template radio button is selected then click on the Next button.
Visual Studio 2013 - Export Template Wizard

4. On the second window of the Export Template Wizard provide the template name, description, an icon and a preview image. From these properties, the template name is the only one which is a required field.

There are also some options such as the “Automatically import the template into Visual Studio” option whose checkbox is selected by default. If you leave it as selected, then the resulting project template zip file will be copied to the C:\Users\\Documents\Visual Studio 2013\Templates\ProjectTemplates folder.

The next time you open the Create new project window, you will find there your newly created template. (If you use this example project, it will be under the Visual C# section)
Visual Studio 2013 - Export Template Wizard step 2

5. Click on the Finish button.

Details of the created template
The different info you provided for your template will appear this way:

Using your new visual studio 2013 template

Some thoughts of the icon and preview image you can use:

  • You can use png, gif, jpg and ico formats for both the preview and the icon images.
  • The preview image will be displayed at the right side of the New project window (see image above) and will be resized so it fits a 200px X 200px square.
  • The icon image will be displayed in the middle of the window and will be resized to fit a 32px X 32px square if the Medium icons option is selected or it will be resized to fit a 16px X 16px square if the small icons option is selected.

Let see an example where your images are not as fancy as the first time 😉

Template without fancy icons

You can downloaded the source code from here.


One thought on “How to create a Visual studio 2013 project template

  1. Pingback: How to create a VSIX project in Visual Studio 2013 | Bits and pieces of programming

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s