This documentation is archived and is not being maintained.

How to: Add References to Templates

Use these procedures to create templates that contain references to assemblies.

Project templates always include a project file, which provides a way to add or remove references in the template.

To add references in project templates

  1. On the File menu, click New, and then click Project.

  2. In the New Project dialog box, select the template that you want to update, enter a name and location for your project, and click OK.

  3. Add or remove references to the project with the Add Reference dialog box. For more information on adding references, see How to: Add or Remove References in Visual Studio (Visual Basic).

  4. Use the Export Template wizard to create a new template. For more information, see How to: Create Starter Kits.

  5. Once the updated template is compressed into a .zip file, delete the old template .zip file.

Item templates do not contain project files, which makes adding references to item templates different than adding references to project templates. You can add references to item templates through the Export Template wizard, or by manually editing the .vstemplate file in the template.


For the template to work correctly, every computer that uses it must have every referenced assembly installed. If it is possible that some computers will not have the assemblies installed, share the assemblies in the same location that you share the template, and have users install the assemblies on their computers. For information on installing assemblies, see How to: Install an Assembly into the Global Assembly Cache.

To use the Export Template wizard to add references in item templates

  1. Create or open a project in Visual Studio.

  2. Add an item to the project and modify if necessary.

  3. On the File menu, click Export Template.

  4. Click Item Template, select the project that contains the item, and click Next.

  5. Select the item to create a template for, and click Next.

  6. Select the assembly references to include in the template, and click Next.


    The list of assemblies is generated from the assembly references in the current project. If the assembly you want to reference does not appear in the list, exit the wizard and add the reference to your project, and then run the wizard again.

  7. Enter the icon file name, template name, and template description, and click Finish.

  8. If you modified an existing template, delete the old .zip template file.

Alternatively, you can manually edit the .vstemplate file to add references to the item template.

To manually add references in item templates

  1. Locate the .zip file that contains the template.

  2. Extract the .zip file.

  3. Open the .vstemplate file in Visual Studio.

  4. In the TemplateContent element, add a References element.

  5. In the References element, add one or more Reference elements to contain the assemblies to reference.

  6. In each Reference element, add an Assembly element with the assembly to reference. For example:

                    System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089
                    System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089

    Assemblies must be referenced using their strong names.

  7. Save and close the .vstemplate file.

  8. Select the files included in your template, right-click, select Send To, and click Compressed (zipped) Folder. The files that you selected are compressed into a .zip file.

  9. Delete the extracted template files and the old template .zip file.

  10. Place the new .zip file in the same directory as the deleted .zip file.