4

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.

Reznoir
  • 909
  • 1
  • 11
  • 27
  • I lost a lot of hair on this. I remember you *must* have two separate projects: one for the code (the VSIX extension), and another one for the templates. The templates one is like a placeholder that the VSIX msbuild task use to add to the main VSIX deployment package. This is the only layout that works, I never managed to have only one VSIX project with code and templates. – Simon Mourier Aug 14 '18 at 09:53
  • Hi Simon, yes I found the same. Sorry if it wasn't clear but I am using two projects one itemtemplate project and one VSIX project - I've updated my question to reflect this. – Reznoir Aug 14 '18 at 10:01
  • Are you using the latest VS 2017? I don't have the same properties that you have and my VSIX sub path is unset (the default). – Simon Mourier Aug 14 '18 at 10:12
  • Yes it's VS2017 (15.7.4) not bang up to date but almost. The ItemTemplate project has been added as a reference project in the VSIX project using the Assets section in the vsixmanifest. The properties in that image are the properties of the ItemTemplate project in the references section of the VSIX project. I hope that makes sense. Again i'll edit my question – Reznoir Aug 14 '18 at 11:20

1 Answers1

5

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

Reznoir
  • 909
  • 1
  • 11
  • 27
  • Is there any specific thing you need to config in order to get item template installed? I have vsix package installed with item template, but I couldn’t find item from add new item dialog – Vincent Feb 19 '22 at 10:38
  • Did you check the box "Automatically import the template into Visual Studio"? If you write a question I can try to help you – Reznoir Feb 21 '22 at 14:36