Visual Studio 2013/2015 C++ 项模板丢失

我正在尝试为 Visual Studio 2013(专业)C++ 项目制作一些简单的项目模板,但 Visual Studio 似乎在与我作斗争.我开始使用 File ->导出模板... 向导,它完成并生成了一个 zip 文件,但遗憾的是,新模板在 Add New Item 对话框中无处可见,所以我开始手动编辑它看看我能不能解决它.

I am trying to make some simple Item Templates for Visual Studio 2013 (Professional) C++ projects, but Visual Studio seems to be fighting with me. I started using the File -> Export Template... wizard, which completed and generated a zip file, but alas, the new template was nowhere to be seen on the Add New Item dialog, so I started manually editing it to see if I could fix it.

这是我的测试 .vstemplate 文件:

Here is my test .vstemplate file:

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
  <TemplateData>
    <DefaultName>test</DefaultName>
    <Name>Test</Name>
    <Description>Test item template.</Description>
    <ProjectType>VC</ProjectType>
    <!--<SortOrder>10</SortOrder>-->
    <Icon>icon.ico</Icon>
  </TemplateData>
  <TemplateContent>
    <ProjectItem TargetFileName="$fileinputname$.h" ReplaceParameters="true">test.h</ProjectItem>
  </TemplateContent>
</VSTemplate>

我尝试将 VCVisualC 用于 <ProjectType> 并将模板放在各种文件夹中,包括压缩和扩展形式.

I've tried using both VC and VisualC for <ProjectType> and placing the template in various folders, in both zipped and expanded forms.

在将 更改为 CSharp 并创建一个 C# 项目后,它立即显示出来.有趣的是,如果 %USERPROFILE%DocumentsVisual Studio 2013TemplatesItemTemplatesVisual C# 目录为空,则模板现在将显示在 %USERPROFILE%DocumentsVisual Studio 2013TemplatesItemTemplates%USERPROFILE%DocumentsVisual Studio 2013TemplatesItemTemplatesVisual C++ Project 目录,但如果它的副本也在 >Visual C# 目录它在新项目对话框中出现两次...

After changing <ProjectType> to CSharp and creating a C# project it shows up immediately. Interestingly, if the %USERPROFILE%DocumentsVisual Studio 2013TemplatesItemTemplatesVisual C# directory is empty, the template will now show up if it is in %USERPROFILE%DocumentsVisual Studio 2013TemplatesItemTemplates or %USERPROFILE%DocumentsVisual Studio 2013TemplatesItemTemplatesVisual C++ Project directories, but if a copy of it is also in the Visual C# directory it shows up twice in the new item dialog...

我知道 Visual Studio 2013 Express RC 存在一个错误,其中新建项目"对话框根本不会显示任何模板,甚至是内置模板,所以我认为这可能是 Visual Studio 中的一个错误,或者只是微软对 C++ 令人不安的漠视的另一个例子.

I know there was a bug with the Visual Studio 2013 Express RC where the New Item dialog wouldn't show any templates at all, even the built-in ones, so I'm thinking this might be a bug in Visual Studio, or just another example of Microsoft's disturbing disregard for C++.

这里有什么我遗漏的地方还是 VS2013 的错误?如果是这样,有人知道任何解决方法吗?

Is there something I'm missing here or is this a bug with VS2013? If so does anyone know of any workaround?

这个问题在 Visual Studio 2015 RC 中仍然存在

This problem still exists in Visual Studio 2015 RC

推荐答案

遇到同样的问题.对我有用的解决方法是使用 VS2013 Express 版本,其中 C++ 项模板工作得很好(就像它们在 VS2012 Pro/Express 中所做的一样).我不知道为什么这个方便的功能已从 Pro 版中删除,但在免费快速版中继续工作.

Having the same problem. The workaround that works for me is to use the VS2013 Express edition, where C++ Item templates work just fine (just like they did in VS2012 Pro/Express). I have no clue why this handy functionality has been removed from the Pro edition but keeps on working in the free express edition.

相关文章