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
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" 
<Name>Timer Job</Name>
<Description>Add a new timer job</Description>
System.Web, Version=, Culture=neutral,
<Assembly>Microsoft.SharePoint, Version=, Culture=neutral,
 PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL</Assembly>
<Folder Name="FolderName">
<ProjectItem SubType="Code" 
             <ProjectItem SubType="Code" 
<ProjectItem SubType="Code" 
<Assembly>Wiz.CustomWizard, Version=, Culture=neutral, 
PublicKeyToken=d24561bc194c5ab4, Custom=null</Assembly>

No comments: