Jonnus
Jonnus

Reputation: 3028

Unable to Add/Update New Template to Visual Studio

I have created a multi-project solution template for Visual Studio 2015.

I managed to upload this to the local template area ...\My Documents\Visual Studio 2015\Templates\ProjectTemplates and it worked fine.

I then decided to make a change to the template (improving the use of the $safeprojectname$ tag), recompiled the template into the zip file, redeployed it to the location above, and... nothing. The existing one has gone, and I can't get the New Project window to display my new template.

I have tried the following to resolve this

I then hit upon the idea of creating a VSIX package for the Template, and while my template appears in the Extensions and Updates window, it still doesn't appear in the New Project window.

enter image description here

enter image description here

As I'm sure someone will ask, here is the *.vstemplate file

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

The most annoying thing is, it worked once. Is there some form of cahcing VS2015 is doing somewhere where you can't repeatedly upload templates with the smae name? How could you go about clearing this cache if it exists?

Upvotes: 0

Views: 269

Answers (2)

Jonnus
Jonnus

Reputation: 3028

After attacking this problem again, bearing in mind the consideration this could be an erroneous template I found the 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.

This was exactly my problem - selecting the folder and zipping that appears to cause a zip file in the wrong format to be interpreted as a Template. Selecting the files within the folder and zipping them together creates a zip file of a slightly different arrangement, which can then be interpreted as a template.

This must have been what I did the one time it worked without realising it.

Thanks to @user1585345 for the suggestion of looking again at the format of the template rather than what VS2015 was doing with it.

Upvotes: 1

bbsimonbb
bbsimonbb

Reputation: 28982

Could this be a problem with the validity of the template, rather than the VS caching? Could you try packaging up a known good project template in your vsix, and seeing if the change gets picked up?

Upvotes: 0

Related Questions