无法 Add/Update 新模板到 Visual Studio

Unable to Add/Update New Template to Visual Studio

我已经为 Visual Studio 2015 年创建了一个多项目解决方案模板。

我设法将其上传到本地模板区域...\My Documents\Visual Studio 2015\Templates\ProjectTemplates并且效果很好。

然后我决定对模板进行更改(改进 $safeprojectname$ 标记的使用),将模板重新编译到 zip 文件中,将其重新部署到上面的位置,然后......什么都没有。现有的已经消失,我无法让新项目 window 显示我的新模板。

我尝试了以下方法来解决这个问题

然后我想到为模板创建 VSIX 包,虽然我的模板出现在扩展和更新中 window,但它仍然没有出现在新项目中 window.

我敢肯定有人会问,这是 *.vstemplate 文件

<VSTemplate Version="3.0.0" Type="ProjectGroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
  <TemplateData>
    <Name>XXXXXX MVC Application Template</Name>
    <Description>Template for new MVC Applications</Description>
    <ProjectType>CSharp</ProjectType>
    <ProjectSubType>
    </ProjectSubType>
    <SortOrder>1001</SortOrder>
    <CreateNewFolder>true</CreateNewFolder>
    <DefaultName>ESITUK_Template</DefaultName>
    <ProvideDefaultName>true</ProvideDefaultName>
    <LocationField>Enabled</LocationField>
    <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
    <Icon>__TemplateIcon.png</Icon>
    <PreviewImage>__PreviewImage.jpg</PreviewImage>
  </TemplateData>
  <TemplateContent>
    <ProjectCollection>
      <ProjectTemplateLink ProjectName="$projectname$.Data">
        XXXXXX_Template.Data\Data.vstemplate
      </ProjectTemplateLink>
      <ProjectTemplateLink ProjectName="$projectname$.Service">
        XXXXXX_Template.Service\Service.vstemplate
      </ProjectTemplateLink>
      <ProjectTemplateLink ProjectName="$projectname$.Web">
        XXXXXX_Template.Web\Web.vstemplate
      </ProjectTemplateLink>
    </ProjectCollection>
  </TemplateContent>
</VSTemplate>

最烦人的是,它只工作了一次。是否有某种形式的缓存 VS2015 正在做一些你不能用 smae 名称重复上传模板的地方?如果存在此缓存,您将如何清除它?

这会不会是模板有效性的问题,而不是VS缓存的问题?您能否尝试在您的 vsix 中打包一个已知的良好项目模板,并查看更改是否被采纳?

再次解决这个问题后,考虑到这可能是一个错误的模板,我找到了 following answer to a similar question

The trick is after editing the unzipped contents of the archive, instead of selecting the folder and zipping that, open the folder and select all the files (and folders if present), and zip those instead.

这正是我的问题 - 选择文件夹和压缩似乎导致错误格式的 zip 文件被解释为模板。选择文件夹中的文件并将它们压缩在一起会创建一个排列略有不同的 zip 文件,然后可以将其解释为模板。

这一定是我在没有意识到的情况下所做的一次。

感谢 @user1585345 再次查看模板格式的建议,而不是 VS2015 用它做什么。