ASNA Visual RPG for .NET (AVR) comes with many project templates. The templates provided are generally serviceable, but wouldn’t it be handy to be able to create your own templates? This way each time you start a new project it’s got just the things you want, the basic forms you need, and all the extra goodies you usually use. And wouldn’t it be nice to make many of those to suit different your application challenges!

This article takes a look at how to create new Visual Studio project templates from existing projects. It’s very easy to do and really ramps up productivity starting new projects. Templates are easy to add, modify, and delete so there’s no risk involved. If a template isn’t working out, you can change or delete it and start over. The techniques shown in this article apply to both VS 2013 and VS 2015. This article describes creating new project templates–used to start new projects. You can also create item templates to provide templated project components (such as custom Web forms).

Getting started

To create a new Visual Studio project template, you first need a working project to serve as the template. This project can be any type of Visual Studio project (which generally means a Windows app, an ASP.NET Website, or a console app). When you get a project to the stage where you’d like it to be reproducible as a project template:

1. Open the project in Visual Studio
Open this project in Visual Studio as if you were going to modify it or use it as the basis for a new app.

2. Start template export with File->Export Template
Start template export by selecting File->Export Template from the top-level menu (as shown below).

Note: Starting with Visual Studio 2017, the Export Template menu option is available from the top-level WebSite menu for Web apps and from the top-level Project menu for Windows apps. You can also use the Visual Studio "Quick Launch" feature in the upper right-hand corner of Visual Studio to search for "export."

3. Choose Template Type

The “Choose Template Type” of the Export Template Wizard is displayed.

Click the “Project Template” radio button and leave the “From which project would you like to create a template” set to whatever its displayed value is (which is the name of the project–as dictated by its top level folder name ). Set the language category to “Visual RPG.”

Click the “Next” button.

4. Select Template Options

The “Select Template Options” page of the Export Template Wizard is displayed.

Set the “Template name” and “Template description” to appropriate values.

I usually find a 32x32 .ico file (there a zillion free-for-commercial-use .ico files on the Web) to use for the "Icon Image" and leave the "Preview Image" empty. If you don’t specify images here Visual Studio provides defaults. Microsoft specs for the images are terse, to say the least, but this blog post provides a little detail.

Leave the two check boxes checked and click the “Finish” button.

The project template is saved in:

C:\Users\roger\Documents\Visual Studio 20xx\My Exported Templates

and a Windows Explorer window is opened showing you the updated contents of that folder (where ‘xx’ is the version year of your copy of Visual Studio). Following the directions above you should see a file named

AVR Basic Web Site

in the Windows Explorer listing. Visual Studio zipped up the project and put it here for you to use as a template. If you poke around on your system you’ll find instances of this file in a couple of folders that Visual Studio uses for caching.

Using a new custom template

Close the project so that nothing is loaded in Visual Studio. Then use File->New->Web Site…” to start a new Web Site. When you select Visual RPG you’ll see the templates available and one of them should be your new template (in this example, it’s named AVR Basic Web Site Template).

When you select that template you’ll get a new instance of the project used to create that template. This new instance is completely independent of the template. Any changes you make to a project based on a template are not reflected back in the template.

Updating a custom template

Create a new project (with any name) based on the template you want to update. Make (and test!) changes to the new project. When you’re ready to update the template from this updated project, repeat the steps above using exactly the same template name you used when you created the template (as shown in Step 4). When you click “Finish” in Step 4, Visual Studio asks if you want to overwrite the existing template. Answer “Yes” to this dialog. The template has now been updated and the new version is ready to use. See this page for more information on updating templates.

Deleting a custom template

Unfortunately, Microsoft doesn’t provide a direct way to delete custom templates. Doing so requires a manual process that requires finding and deleting files on the disk associated with the template. This example shows how to delete a custom template named AVR Empty Web Site Template.

First, find all occurrences of the target template with the DOS command line. All template occurrences template will be located under the


folder, so start the search there.

cd \user\<username>
dir <exact template name>.zip /s

The resulting DOS screen, shown above, shows three template-related things to delete. At first glance, it looks like there are three zip files to delete. Look closely, the first entry isn’t a file, but rather it’s a folder. Note that the exact folder names displayed depend on what version of Visual Studio you’re using.

Using either the DOS command line or Windows’ Explorer, delete that folder and the two zip files from your system. After doing that, the template will no longer be displayed in Visual Studio’s template list. If you left Visual Studio opened while deleting templates, be sure to exit and restart Visual Studio.