我遇到了一个自定义项模板没有显示在Visual Studio 2022中的"添加新项"上的问题.
该模板是通过使用VS2022中的ASP.NET Core项目中的"导出为模板"创建的,并选中了"自动导入到Visual Studio"选项.模板已成功导出并显示在%USER_NAME%\Documents\Visual Studio 2022\Templates\ItemTemplates
目录中.
但是,当试图通过ASP.NET Core 7.0项目中的"Add New Item"添加项时,项does not显示为模板.
但是,项does在添加到.NET框架4.7.2项目时出现.这说明我和它相比,至少拿起了模板.
.vstemplate
代码:
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>IndexTest.cshtml</DefaultName>
<Name>IndexTest</Name>
<Description><No description available></Description>
<ProjectType>CSharp</ProjectType>
<SortOrder>10</SortOrder>
<Icon>__TemplateIcon.ico</Icon>
</TemplateData>
<TemplateContent>
<References />
<ProjectItem SubType="" TargetFileName="$fileinputname$.cshtml" ReplaceParameters="true">Index.cshtml</ProjectItem>
<ProjectItem SubType="" TargetFileName="$fileinputname$.cshtml.cs" ReplaceParameters="true">Index.cshtml.cs</ProjectItem>
</TemplateContent>
</VSTemplate>
该模板被部署到ItemTemplates
目录的根目录.
如何使此模板出现在ASP.NET核心项目中?
我试着添加<TemplateGroupID>AspNetCore</TemplateGroupID>
元素,但没有成功.