Custom Visual Studio 2015 project templates

How to create and use a customized Visual Studio 2015 project template.

This document was updated on October 11, 2015.


Easy ‘new project’ creation

A well-configured app – web app, or web service – requires a lot of work.

Often, you create a new project with the “ASP.NET Web Application” template, with or without an authentication component.

Then, you may have to add the Entity Framework. And AutoMapper. And several other components.

Next, you create a file for your design model classes. And many others.

It would be nice to save all this work as a ‘template’ that you could reuse for new projects.

Can you do that?



Visual Studio 2015 “Export Template”

Configure a project with the components and files you want.

Do you want to include a database with the template?

If yes, do the following:

In Solution Explorer, locate the database in the App_Data folder. You may have to “Show All Files” on the Solution Explorer toolbar.

Next, right-click the database item, and choose “Include in Project”.

Then, right-click the database item, and choose “Properties”. Change the “Copy to Output Directory” setting to “Copy Always”.


Next, on the Visual Studio 2015 “File” menu, choose “Export Template” to start the wizard.

Select “Project template”, and go to the next panel.

Complete these fields:

  • Template name (keep the name short)
  • Template description (it appears that this is limited to about 250 characters)
  • Icon image (can be ico, png, jpg)

For the icon image, you can use this, if you wish:



Un-check (clear) the “Automatically import the template into Visual Studio” checkbox.




Click the Finish button.


Update some settings

There are two important changes that must be done to the project template before use:

  1. Update the database “initial catalog” value
  2. Edit the hosting information

First, use the built-in Windows File Explorer functionality to “Extract All…” to a folder with the same name as the project template.

In that folder, edit Web.config (in Notepad). After the “attachdbfilename” value, add this new key-value pair:

initial catalog=DB$safeprojectname$;

Next, edit the .csproj file (in Notepad). Locate the “DevelopmentServerPort” element. Clear its value. After the edit, it will look like this:


Then, locate the “IISUrl” element. Clear its value. After the edit, it will look like this:


We can now repackage the zip file. Use this special procedure to do this:

  1. Ensure that you are still in the folder that has Web.config and the .csproj file.
  2. Select all the files and folders (Ctrl+A).
  3. Right-click one of them, and choose Send to > Compressed (zipped) folder.
  4. The name of the zip must be the same as the project template name.


Move the project template to Visual Studio

Select and copy the zip file that matches the template you just exported.

Navigate to this folder. You must create the “Web” subfolder:

%userprofile%\Documents\Visual Studio 2015\Templates\ProjectTemplates\Visual C#\Web


Paste the zip file into this folder.

Your new template will now appear when you create a new project in Visual Studio.

The image below shows how the wizard values match up to the items in the New Project dialog. Click to view full-size in its own tab/window.





Other supporting info

MSDN: How to: Locate and Organize Project and Item Templates

Visual Studio Magazine: Develop Faster with Customized Visual Studio Templates 
(read the part about creating your own custom folder/container for the left-side navigator)

















%d bloggers like this: