Logo
HOWTO: Changing the source code of templates used by Visual Studio .NET wizards

Author: Carlos J. Quintero (Microsoft MVP) Applies to: Microsoft Visual Studio .NET 2002
Date: July 2004   Microsoft Visual Studio .NET 2003
Updated March 2013   Microsoft Visual Studio 2005
      Microsoft Visual Studio 2008
      Microsoft Visual Studio 2010
      Microsoft Visual Studio 2012
Introduction

Sometimes you may want to change the source code of the templates used by Visual Studio .NET when you invoke them, for example the several templates that appear in the Add New Item dialog of Visual Studio .NET or the templates used by Visual Studio .NET Add-In Wizards. You may also want to change the default references that are added to each project kind.

More Information

For Visual Studio .NET 2002/2003:

The most usual folders for Visual Basic .NET and C# project templates (assuming a default English installation of Visual Studio .NET) are:

  • VB.NET templates:

The root folder for templates is <VisualStudioInstallDir>\Vb7\VBWizards. For example, C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\VBWizards for Visual Studio .NET 2003.

Inside this folder, you must select the subfolder which matches the item kind that you are interested in (for example, WindowsApplication) and inside it you have the Templates\1033 folder which contains the templates used by this kind of item (for example, the WindowsApplication.vbproj, AssemblyInfo.vb and Form.vb templates).

For add-in projects, the folder for the templates is <VisualStudioInstallDir>\Common7\IDE\Extensibility Projects\VBasic. Inside it, you have the Project1.vbproj, AssemblyInfo.vb and Connect.vb templates.

  • C# templates:

The root folder for templates is <VisualStudioInstallDir>\VC#\VC#Wizards. For example, C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\VC#Wizards for Visual Studio .NET 2003.

Inside this folder, you must select the subfolder which matches the item kind that you are interested in (for example, CSharpAddWinFormWiz) and inside it you have the Templates\1033 folder which contains the templates used by this kind of item (for example, the NewWinForm.cs template).

For add-in projects, the folder for the templates is C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\Extensibility Projects\CSharp. Inside it, you have the Project1.csproj, AssemblyInfo.cs and Connect.cs templates.

For Visual Studio 2005 and higher:

Visual Studio 2005/2008 uses a folder to store installed templates and a different folder as a cache (which is the one that actually uses). So, you need to change the templates in the first folder and then update the cache.

The folder with the installed templates is:

  • <VisualStudioInstallDir>\Common7\IDE\ItemTemplates\Language\Locale\  for file templates
  • <VisualStudioInstallDir>\Common7\IDE\ProjectTemplates\Language\Locale\ for project templates

Where Language can be "VisualBasic", "CSharp", etc. and Locale is 1033 for English, etc.

The folder with the templates cache is:

  • <VisualStudioInstallDir>\Common7\IDE\ItemTemplatesCache\Language\Locale\  for file templates
  • <VisualStudioInstallDir>\Common7\IDE\ProjectTemplatesCache\Language\Locale\ for project templates

To rebuild the cache you need to open a Visual Studio command prompt ("Start", "Programs", "Microsoft Visual Studio <version>", "Visual Studio Tools", "Visual Studio <version>" Command Prompt" and type:

devenv.exe /installvstemplates

Remarks

  • Before modifying the templates it is recommended to make a backup copy.  

Go back to the 'Resources for Visual Studio .NET extensibility' section for more articles like this


Top