我有一个VisualStudio2017项模板扩展,目前正在使用ASP.NET项目。它有以下.vstemplate:
<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>Angular Component</Name>
<Description>Files for an Angular component</Description>
<RequiredFrameworkVersion>4.5</RequiredFrameworkVersion>
<Icon>AngularComponentTemplate.ico</Icon>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>Web</ProjectSubType>
<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
</TemplateData>
<TemplateContent>
<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.component.html">base.component.html</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.component.ts">base.component.ts</ProjectItem>
</TemplateContent>
</VSTemplate>此外,它引用的VSIX文件
ItemTemplate\CSharp\Web
为项目的"VSIX子路径“属性设置。
但是,我不能让这个模板出现在ASP.NET核心项目中。我试过在vstemplate中使用这个:
<ProjectType>DNX</ProjectType>
<TemplateGroupID>SharedDotNetAndDotNetWeb</TemplateGroupID>(来自https://stackoverflow.com/a/38543920/1783619)但没有奏效。在发布的Visualstuido2017版本中,如何使项目模板出现在.NET核心项目中?
发布于 2017-05-29 00:38:44
在为pug文件创建项目模板时,我也遇到了同样的问题。
以下是我所做的:
首先,我了解了股票模板是如何写成的:
C:\程序文件(x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ItemTemplates\AspNetCore
我的模板是这样的:
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>page.pug</DefaultName>
<Name>Pug File</Name>
<Description>This is a basic pug file template (previously Jade)</Description>
<ProjectType>CSharp</ProjectType>
<TemplateGroupID>AspNetCore</TemplateGroupID>
<TemplateID>AspNetCore.Pug</TemplateID>
<NumberOfParentCategoriesToRollUp>2</NumberOfParentCategoriesToRollUp>
<Icon>__TemplateIcon.ico</Icon>
<PreviewImage>__PreviewImage.ico</PreviewImage>
<SortOrder>10</SortOrder>
<ShowByDefault>false</ShowByDefault>
</TemplateData>
<TemplateContent>
<References />
<ProjectItem ReplaceParameters="true">page.pug</ProjectItem>
</TemplateContent>
</VSTemplate>需要注意的领域: ProjectType、TemplateGroupId、TemplateId(自己编)和NumberOfParentCategoriesToRollUp
我希望我的模板主要显示在"Content“类别中,其中HTML和CSS类型模板都在其中,所以我将zip文件放在
Visual Studio 2017\Templates\ItemTemplates\Visual C#\AspNetCore\Web\Content我必须创建几个目录(AspNetCore\Web\Content)才能得到这种结构。
然后将"NumberOfParentCategoriesToRollUp“设置为2,允许模板在"Content”类别中显示,但也可以“滚动”并显示在Web和AspNetCore类别中。
有关模板组织的更多信息,请参见:
然后,完成之后,打开visual studio 2017 developer命令提示符并键入:
devenv /updateconfiguration发布于 2018-08-30 08:50:07
最重要的是
<TemplateGroupID>AspNetCore</TemplateGroupID>否则,您将无法从ASP.NET核心项目中看到项目模板。
奇怪的是,您将看到您的项目模板与其他项目(例如桌面)。
希望微软有一天能记录下来或者让事情变得更简单。
https://stackoverflow.com/questions/44030522
复制相似问题