Visual Studio Custom Template Category has an extra folder

835 views Asked by At

I have created an ItemTemplate project. I would like to install this to a custom folder. This works fine when I manually add the zip file built from the project to my named folder inside ItemTemplates.

I am now using two projects, the original ItemTemplate project and a VSIX project for the installation.

The issue that I am facing is that when using a VSIX project to install the template the installation path adds an extra folder called CSharp inside my custom folder. This only happens when I add the ItemTemplate project to the VSIX project as a project. If I add the output of the ItemTemplates project, the zip file, to the VSIX project the template is located in the correct place.

This is how it currently looks This is how it currently looks


and this is what I want it to look like. enter image description here


The ItemTemplate project has been added as a reference project in the VSIX project using the Assets section in the vsixmanifest. The properties in the image below are the properties of the ItemTemplate project in the references section of the VSIX project. VSIX Settings


If it helps this is the vstemplate file that I use in the ItemTemplate project.

<?xml version="1.0" encoding="utf-8"?>
<VSTemplate Version="3.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" xmlns:sdk="http://schemas.microsoft.com/developer/vstemplate-sdkextension/2010">
  <TemplateData>
    <Name>Generator</Name>
    <Description></Description>
    <Icon>Magic.Generator.ico</Icon>
    <TemplateID>Magic.Generator</TemplateID>
    <TemplateGroupID>Magic</TemplateGroupID>
    <ProjectType>CSharp</ProjectType>    
    <RequiredFrameworkVersion>2.0</RequiredFrameworkVersion>
    <NumberOfParentCategoriesToRollUp>2</NumberOfParentCategoriesToRollUp>
    <DefaultName>Generator.cs</DefaultName>
  </TemplateData>
  <TemplateContent>
    <ProjectItem ReplaceParameters="false">Generator.cs</ProjectItem>
  </TemplateContent>
</VSTemplate>

Im using VS2017 (15.7.4) Any help is appreciate, thank you.

1

There are 1 answers

2
Reznoir On BEST ANSWER

I have figured it out. Hopefully this will be useful to others.

A comment from Simon Mourier (thanks Simon) made me think about the problem in a bit of a different way.

I had been thinking that the VSIX project contained all the information about where to install the ItemTemplate, however this is not the case, it is actually the ItemTemplate project itself that contains this information.

From this I discovered that if you look at the properties of the vstemplate file in the ItemTemplate project you will find a Category field this is what you need to set.

vstemplate settings