Visual Studio 2017 Custom Item Templates for .Net Core 2.1

Viewed 821

Following the instructions at this doc, I

  1. Created a new "ASP.NET Core Web Application" and selected "API" from the follow on menu.
  2. I made a small change to the provided "ValuesController.cs", then clicked Project > Export Template.
  3. Selected "Item template", clicked next
  4. Selected "ValuesController.cs" from the controllers folder, clicked next.

  5. Didn't check any dependencies, clicked next

  6. Named it "MyControllerTemplate" and didn't add any icons. clicked finish

After all that, I ended up with "MyControllerTemplate.zip" in two places:

  1. Visual Studio 2017 > My Exported Templates
  2. Visual Studio 2017 > Templates > ItemTemplates

According to the doc, that should have been enough. After closing and reopening VS2017, I go to add a new item, and my installed choices are limited to Xamarin.Forms and ASP.NET Core, neither of which have my newly created template.

I also tried it again after extracting the zip file in both places.

Based on another stack overflow, I also tried changing <ProjectType>CSharp</ProjectType> to <ProjectType>DNX</ProjectType> in the .vstemplate file.

and adding <TemplateGroupID>SharedDotNetAndDotNetWeb</TemplateGroupID>

as well as <TemplateGroupID>DotNetWeb</TemplateGroupID>

None of this has made the template visible to me.

Is there something else I need to do, or a step I am messing up?

Edit 1: Tried moving the zip file and extracted files into the Visual C# folder under ItemTemplates, neither worked.

1 Answers

My solution was extracting the zip file, editing the .vstemplate file to add <TemplateGroupID>AspNetCore</TemplateGroupID> to the <TemplateData> section, and leaving <ProjectType>CSharp</ProjectType> alone

Related