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
On the File menu, click New, and then click Project.
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.
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.
Use the Export Template wizard to create a new template. For more information, see How to: Create Starter Kits.
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
Create or open a project in Visual Studio.
Add an item to the project and modify if necessary.
On the File menu, click Export Template.
Click Item Template, select the project that contains the item, and click Next.
Select the item to create a template for, and click Next.
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.
Enter the icon file name, template name, and template description, and click Finish.
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
Locate the .zip file that contains the template.
Extract the .zip file.
Open the .vstemplate file in Visual Studio.
In the TemplateContent element, add a References element.
In the References element, add one or more Reference elements to contain the assemblies to reference.
In each Reference element, add an Assembly element with the assembly to reference. For example:
<TemplateContent> <References> <Reference> <Assembly> System, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b77a5c561934e089 </Assembly> </Reference> <Reference> <Assembly> System.Data, Version=18.104.22.168, Culture=neutral, PublicKeyToken=b77a5c561934e089 </Assembly> </Reference> </References> ... </TemplateContent>
Assemblies must be referenced using their strong names.
Save and close the .vstemplate file.
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.
Delete the extracted template files and the old template .zip file.
Place the new .zip file in the same directory as the deleted .zip file.