views:

34

answers:

1

Hi all

I've followed this tutorial to try to add a template to Visual Studio:

http://www.switchonthecode.com/tutorials/visual-studio-how-to-create-item-templates

The template I have created is designed to add one predefined .aspx and one predefined .aspx.cs file to the project.

The folder contains the following files:

MoosePage.aspx

MoosePage.aspx.cs

MoosePage.vstemplate

MoosePageItemTemplateIcon.ico

The .vstemplate file looks like this:

<VSTemplate Type="Item" Version="2.0.0"
   xmlns="http://schemas.microsoft.com/developer/vstemplate/2005"&gt;
  <TemplateData>
    <Name>MoosePage</Name>
    <Description>MoosePage Template</Description>
    <DefaultName>NewMoosePage</DefaultName>
    <ProjectType>CSharp</ProjectType>
    <Icon>MoosePageItemTemplateIcon.ico</Icon>
  </TemplateData>
  <TemplateContent>
    <ProjectItem TargetFileName="$fileinputname$.aspx" ReplaceParameters="true">
      MoosePage.aspx
    </ProjectItem>
    <ProjectItem TargetFileName="$fileinputname$.aspx.cs" ReplaceParameters="true">
      MoosePage.aspx.cs
    </ProjectItem>
  </TemplateContent>
</VSTemplate>

I have zipped the files up (.zip not .zipx) and placed the zip folder in My Documents\Visual Studio 2008\Templates\ItemTemplates\VisualWebDeveloper.

I have restarted Visual Studio.

When I go into my website project and choose Add New Item, I don't see my new template.

Can anyone suggest what might have gone wrong?

Thanks

David

A: 

I have found out there is a wizard to create templates in File -> Export Template.

Using this wizard, I found out that my .vstemplate file had the wrong ProjectType. I changed it to this...

<VSTemplate Type="Item" Version="2.0.0"
   xmlns="http://schemas.microsoft.com/developer/vstemplate/2005"&gt;
  <TemplateData>
    <Name>MoosePage.aspx</Name>
    <Description>MoosePage Template</Description>
    <DefaultName>NewMoosePage</DefaultName>
    <ProjectType>Web</ProjectType>
    <ProjectSubType>CSharp</ProjectSubType>
    <Icon>MoosePageItemTemplateIcon.ico</Icon>
  </TemplateData>
  <TemplateContent>
    <ProjectItem TargetFileName="$fileinputname$.aspx" ReplaceParameters="true">
      MoosePage.aspx
    </ProjectItem>
    <ProjectItem TargetFileName="$fileinputname$.aspx.cs" ReplaceParameters="true">
      MoosePage.aspx.cs
    </ProjectItem>
  </TemplateContent>
</VSTemplate>

And now it works fine.

I can also confirm that the new .zipx format is NOT supported.

Now to wait two years before I can mark my own answer as correct.

Cheers

David

David