3

I have created a custom template for VS2019 that contains two projects. Below is my root.vstemplate file

<VSTemplate Version="3.0.0" Type="ProjectGroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
  <TemplateData>
    <Name>Asp.Net Core Template EF Core</Name>
    <Description>Asp.Net Core 3.1 Boilerplate template</Description>
    <ProjectType>CSharp</ProjectType>
    <ProjectSubType>
    </ProjectSubType>
    <SortOrder>1000</SortOrder>
    <CreateNewFolder>true</CreateNewFolder>
    <DefaultName>Asp.Net Core Template EF Core</DefaultName>
    <ProvideDefaultName>true</ProvideDefaultName>
    <LocationField>Enabled</LocationField>
    <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
    <Icon>logo.png</Icon>
  </TemplateData>
  <TemplateContent>
    <ProjectCollection>
      <ProjectTemplateLink ProjectName="AspNet Core Ef Core">
        src\AspNetCore3EfCoreTemplate\MyTemplate.vstemplate
      </ProjectTemplateLink>
      <ProjectTemplateLink ProjectName="AspNet Core Ef Core Web">
        src\AspNetCore3EfCoreTemplate.Web\MyTemplate.vstemplate
      </ProjectTemplateLink>
    </ProjectCollection>
  </TemplateContent>
</VSTemplate>

I followed the instructions of this link but my template is not shown when I try to create a new item in VS2019. Anyone knows why is this happening?

1
  • 2
    For the custom project template, the new VS2019 UI for creating projects cannot find custom templates through filters and they actually are exists in it. This behavior is a known issue. Please clear the filter and then you can find your new template near the end of all templates.
    – Mr Qian
    Commented Jan 9, 2020 at 9:15

5 Answers 5

7

I followed the instructions of this link but my template is not shown when I try to create a new item in VS2019. Anyone knows why is this happening?

For the custom project template, the new VS2019 UI for creating projects cannot find custom project templates through filters and these templates actually exist in it.

All Langages, All Platforms and All Project Types and the search box lose the ability to filter custom project templates and this is a known issue in VS2019. But it still happens in the latest version VS2019 16.4.2. If you want to solve this annoying problem, you can report an issue to DC Forum to report this abnormal behavior for support. This might be a long process or you can try my suggestions below:

Suggestion

1) Do not use any filters in VS2019 Project UI and then drag to the bottom of all templates to find the custom template, which is usually inserted after all the default templates.

enter image description here

This picture shows it at the bottom of all templates.

2) change to use VS2017 which has no error about this.

Update 1

l have created with your further info and test in my side without any errors, my environment:

win10 enterprise 1903; VS2019 Community 16.4.2

My Steps:

1) l have created two projects into a same solution: a Net Core 3.1 ClassLibrary project and a ASP.NET Core 3.1 Web Application project.

2) then click Export Template.. in the Project menu and export these projects as project template separately.

3) open the folder and unzip them into the same folder called src.

This shows the two unzip project folders in the src folder

enter image description here

Then, this shows the final form of the folder,and src folder contains the two project folders as the picture shows above

enter image description here

4) root.vstemplate is the code you provide. The project Template is called Asp.Net Core Template EF Core as you said. After that, I compress these two files into a package called multiple projects template,and then put this zip file into this path C:\Users\xxx\Documents\Visual Studio 2019\Templates\ProjectTemplates.

5) then I close VS Instance and then restart VS and clear all the filters and then pull the project templates to the bottom, and then look up at the bottom for a template called Asp.Net Core Template EF Core.

> l have found this template in my side and if you does not see this, please repair VS and then disable any third-party extensions in the Extension-->Manage Extension menu to prevent interference with VS. Besides, since your VS is 16.4.1, you could try to update it to 16.4.2.

Update 2

With your sample, l think l found the issue. The issue is that root.template cannot find the two contained projects:

You put root.template in the Src folder and the root.vstemplate file write these:

src\ClassLibrary1\MyTemplate.vstemplate

src\WebApplication3\MyTemplate.vstemplate

It uses relative paths to find these files and the current path where your root.vstemplate is located does not have src so it cannot find.

The solution is that you should put root.vstemplatein the same directory as the SRC folder and then compress these two. After that, put this Multiple.zip into C:\Users\xxx\Documents\Visual Studio 2019\Templates\ProjectTemplates.

enter image description here

Hope it could help you.

16
  • thanks for your reply. I did what you suggested no filters nothing but still cannot see it there
    – pantonis
    Commented Jan 10, 2020 at 8:23
  • 1
    When you put the xxx.zip file into C:\Users\Admin\Documents\Visual Studio 2019\Templates\ProjectTemplates and then restart your VS, and you can find it near the bottom of the all templates. l just do this, and it actually there.
    – Mr Qian
    Commented Jan 10, 2020 at 8:54
  • I am doing the exact same thing but it is not there. I can send you the template if you wish. just send me an email
    – pantonis
    Commented Jan 10, 2020 at 8:57
  • I tried that and I can see it. That does not answer though what is the problem with my template which is the initial question of this post
    – pantonis
    Commented Jan 10, 2020 at 9:13
  • What is your VS2019 version and what type of the project you include into the template?
    – Mr Qian
    Commented Jan 10, 2020 at 10:02
6

Visual Studio 2019 uses tags to filter projects. By default when you export a project template, the .vstemplate file doesn't contain the required tags. You need to edit the .vstemplate file and add the following tags in the TemplateData section (I.e. between <TemplateData> and </TemplateData>) and replace the values with the appropriate values for your template:

<LanguageTag>Language</LanguageTag>
<PlatformTag>Platform</PlatformTag>
<ProjectTypeTag>Type</ProjectTypeTag>

For example, here is the TemplateData for one of my custom templates:

<TemplateData>
  <Name>MyCaliburnMicroTemplate</Name>
  <Description>Caliburn Micro template I set up with basic localisation, logging, settings and themes implemented.</Description>
  <ProjectType>CSharp</ProjectType>
  <ProjectSubType>Windows</ProjectSubType>
  <LanguageTag>CSharp</LanguageTag>
  <PlatformTag>Windows</PlatformTag>
  <ProjectTypeTag>Desktop</ProjectTypeTag>
  <SortOrder>1000</SortOrder>
  <CreateNewFolder>true</CreateNewFolder>
  <DefaultName>MyCaliburnMicroTemplate</DefaultName>
  <ProvideDefaultName>true</ProvideDefaultName>
  <LocationField>Enabled</LocationField>
  <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
  <Icon>__TemplateIcon.ico</Icon>
</TemplateData>

I also set the <ProjectSubType> to Windows, but I haven't tested to see if this makes any difference.

Here's a picture of my 'Create a new project' window with the filters set to C#, Windows and Desktop:

Visual Studio 2019 - Create a new project window

Notice the tags now appear below the description of my project template. I'm currently using Visual Studio Community 2019 version 16.4.3, but haven't tested this with any other version.

1
  • 1
    This worked for me - adding these tags allowed the template to show with the language, platform and project type filters selected, although not with the search when searching for the name of the template Commented Sep 17, 2020 at 15:33
1

This is what I did to make it work: After the zip file of the template was created, I extracted it. Then I copied the folder to the "ProjectTamplates" folder.

I was able to create a new project based on my template this way.

0

Maybe this will help. https://blog.jayway.com/2015/03/13/visual-studio-how-to-create-a-solution-template-with-multiple-projects/

The original documentation usually miss a step or 2 that looks obvious after you made a lots of templates.

0
0

I was struggling with same issue, that my project does not apper in search window of projects in VS.

In folder "ProjectTemplates" I had zip that was containing dots in name. After removing them my project appeared in projects window in VS.

I hope this will help someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.