Raghu's SharePoint Corner: Template MetaData Files .VSTemplate extensions

My blog has moved!

You will be automatically redirected to the new address. If that does not occur, visit
http://www.sharepointcolumn.com
and update your bookmarks.

May 7, 2009

Template MetaData Files .VSTemplate extensions

To start with VSTemplate, lets first know where are VSTemplate files used.These files are used to create custom ItemTemplate and custom ProjectTemplate.Once these templates are created you can make it appear in the New New Item and the New Project dialog boxes.

1. ItemTemplates: All the templates that appear in the Add New Item Dialog Box are called Item Templates

2. ProjectTemplates: All the templates that appear in the Create/Add New Project Dialog Boxare called Project Templates

Before getting into creation of custom ItemTemplates, lets understand the structure of .VSTemplate which is the core part of Item and Project Templates

The .vstemplate file for project templates consists of three fundamental elements:

1. VSTemplate:  Identifies the template as a project or item template and provides the template version number. The attribute Type for VSTemplate specifies weather its project template or a Item Template

2. TemplateData: Categorizes the project template and defines   display characteristics for the New Project or Add New Item dialog box.It defines the name of the   tempalte,the description of what the template does, its default name and many other attritbute which we will  look into when we create a custom item template in the comnig posts





3. TemplateContent:Specifies the files included in the template.This part of the templates specifes what are the assembly references to be included, what are the default files need to be created when a new item is created usings this template





Apart from the above three fundamental there are other 2 optional sections, which may be needed during creation of custom templates

4. WizardExtension:This custom wizard helps to define additional custom functionality to the custom item templates, like adding the receiver class and the Recevice assembly into the feature dynamically


5. WizardData: This section of the VSTempalte helps us to pass custom xml to the custom wizard extension





Sample VSTemplate structure is shown below


<VSTemplate Version="2.0.0" Type="Item" 
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>Timer Job</Name>
<Description>Add a new timer job</Description>
<ProjectType>CSharp</ProjectType>
<TemplateID>TimerJob</TemplateID>
<ShowByDefault>true</ShowByDefault>
<DefaultName>TimerJob</DefaultName>
<Icon>Icon.ico</Icon>
</TemplateData>
<TemplateContent>
<References>
<Reference>
<Assembly>
System.Web, Version=2.0.0.0, Culture=neutral,
 PublicKeyToken=b03f5f7f11d50a3a
       </Assembly>
</Reference>
<Reference>
<Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral,
 PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL</Assembly>
</Reference>
</References>
<Folder Name="FolderName">
<ProjectItem SubType="Code" 
TargetFileName="feature.xml"
 ReplaceParameters="true">..\feature.xml</ProjectItem>
             <ProjectItem SubType="Code" 
TargetFileName="$rootname$.cs"
 ReplaceParameters="true">..\Job.cs</ProjectItem>
<ProjectItem SubType="Code" 
TargetFileName="$rootname$Installer.cs"
 ReplaceParameters="true">..\JobInstaller.cs</ProjectItem>
</Folder>
</TemplateContent>
<WizardExtension>
<Assembly>Wiz.CustomWizard, Version=1.0.0.0, Culture=neutral, 
PublicKeyToken=d24561bc194c5ab4, Custom=null</Assembly>
<FullClassName>Wiz.CustomWizard.CustWizard</FullClassName>
</WizardExtension>
</VSTemplate>

No comments: