Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can export individual project items as zipped templates using the menu File|Export Template... in VS2010. To create a template with multiple files, you can export the first item, then add additional items to the resulting template zip. You'll also need to edit the .vstemplate file in the zip to include the additional items.</p> <p>As an example, I exported a form from a existing project and then added an xml file. The resulting zip file contains the files</p> <p>__TemplateIcon.ico<br> Form1.cs<br> Form1.Designer.cs<br> Form1.resx<br> MyTemplate.vstemplate<br> xmldata.xml </p> <p>The .vstemplate file contains the following xml:</p> <pre><code>&lt;VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item"&gt; &lt;TemplateData&gt; &lt;DefaultName&gt;TwoFileTemplate&lt;/DefaultName&gt; &lt;Name&gt;TwoFileTemplate&lt;/Name&gt; &lt;Description&gt;Test template&lt;/Description&gt; &lt;ProjectType&gt;CSharp&lt;/ProjectType&gt; &lt;SortOrder&gt;10&lt;/SortOrder&gt; &lt;Icon&gt;__TemplateIcon.ico&lt;/Icon&gt; &lt;/TemplateData&gt; &lt;TemplateContent&gt; &lt;References /&gt; &lt;ProjectItem SubType="" TargetFileName="xml\$fileinputname$.xml" ReplaceParameters="true"&gt;xmldata.xml&lt;/ProjectItem&gt; &lt;ProjectItem SubType="Form" TargetFileName="$fileinputname$.cs" ReplaceParameters="true"&gt;Form1.cs&lt;/ProjectItem&gt; &lt;ProjectItem SubType="" TargetFileName="$fileinputname$.Designer.cs" ReplaceParameters="true"&gt;Form1.Designer.cs&lt;/ProjectItem&gt; &lt;ProjectItem SubType="" TargetFileName="$fileinputname$.resx" ReplaceParameters="true"&gt;Form1.resx&lt;/ProjectItem&gt; &lt;/TemplateContent&gt; &lt;/VSTemplate&gt; </code></pre> <p>Once you've updated the zip file, move it to the folder ...\Visual Studio 2010\Templates\ItemTemplates. </p> <p>The new template should now show up in the Add New Item dialog in VS2010. It will add the form and xml file with whatever name you specify when adding the new item to the project and will put the xml file in a directory named 'xml'. If you want a fixed name for one or the other of the files you can replace <code>$fileinputnam$</code> in the .vstemplate file with the desired name.</p> <p>Edit - If you want a fixed item name for a form or other class file you'll also need to open the code templates and replace <code>$safeitemname$</code> with the desired name.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload