Visual Studio 自定义模板类别有一个额外的文件夹

Visual Studio Custom Template Category has an extra folder

我已经创建了一个 ItemTemplate 项目。我想将其安装到自定义文件夹中。当我手动将从项目构建的 zip 文件添加到 ItemTemplates 中我命名的文件夹时,这工作正常。

我现在使用两个项目,原来的ItemTemplate项目和一个用于安装的VSIX项目。

我面临的问题是,当使用 VSIX 项目安装模板时,安装路径会在我的自定义文件夹中添加一个名为 CSharp 的额外文件夹。只有当我将 ItemTemplate 项目作为项目添加到 VSIX 项目时才会发生这种情况。如果我将 ItemTemplates 项目的输出(zip 文件)添加到 VSIX 项目,模板位于正确的位置。

这是目前的样子


这就是我想要的样子。


ItemTemplate 项目已使用 vsixmanifest 中的“资产”部分添加为 VSIX 项目中的参考项目。下图中的属性是 VSIX 项目的参考部分中 ItemTemplate 项目的属性。


如果有帮助,这是我在 ItemTemplate 项目中使用的 vstemplate 文件。

<?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>

我正在使用 VS2017 (15.7.4) 感谢任何帮助,谢谢。

我想通了。希望这对其他人有用。

来自 的评论(感谢 Simon)让我以不同的方式思考这个问题。

我一直以为 VSIX 项目包含有关 ItemTemplate 安装位置的所有信息,但事实并非如此,实际上 ItemTemplate 项目本身包含此信息。

由此我发现,如果您查看 ItemTemplate 项目中 vstemplate 文件的属性,您会发现一个 Category 字段,这就是您需要设置的内容。