Sunday, February 13, 2011

Set Custom Tool in the Item Template file

Documentation for setting the Custom Tool property for a project item created from an item template is not exactly easily found.

There are two things you need in the .vstemplate-file (I’ll assume you know how to create item templates). First you need to include a WizardExtension-node and next you need to specify a CustomTool attribute on the ProjectItem. Both are marked in yellow below.

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
  <TemplateData>
    <DefaultName>MyFile.txt</DefaultName>
    <Name>My File</Name>
    <Description>My File</Description>
    <ProjectType>CSharp</ProjectType>
    <SortOrder>1</SortOrder>
    <Icon>__TemplateIcon.ico</Icon>
  </TemplateData>
<WizardExtension> <Assembly>Microsoft.VSDesigner, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly> <FullClassName>Microsoft.VSDesigner.ProjectWizard.ItemPropertyWizard</FullClassName> </WizardExtension>
<TemplateContent> <References /> <ProjectItem SubType="Code" TargetFileName="$fileinputname$.txt" ReplaceParameters="false" CustomTool="MyCustomTool">MyFile.txt</ProjectItem> </TemplateContent> </VSTemplate>

0 comments: