2

I got visual studio 2017 enterprise trial, I have installed it twice thinking it was something wrong with the installation, but still everything I export an item template it doesn't get imported into visual studio, I see it inside the exported templates directory, I have looked in %appdata% and %localappdata% at the item caches one didn't show all the templates so I deleted the folder, and next time I ran vs it installed them into there, however it still doesn't show any item templates in the add new item dialog. it seems like it would be a cool feature to use and I really want to use it but it just never shows any item template I export, and I have never tried a project template, if anyone knows how to get this working please help me.

doubletoker
  • 41
  • 1
  • 5

7 Answers7

4

I was having trouble getting project and item templates to appear, then I checked under Tools > Options > Projects and Solutions > General and saw that the path for my templates was set to: %UserProfile%\OneDrive\Documents\Visual Studio 2017\Templates\

...great for keeping them synchronized across machines I guess, but considering I was putting them in %UserProfile%\Documents\Visual Studio 2017\Templates\ that's why they weren't showing up.

So... maybe check to be sure that the path VS has set as the home of the templates is the same path you're placing the templates in. ;)

Bleak Morn
  • 139
  • 1
  • 9
  • 4
    Looks like maybe they moved the location for template paths in the last year of VS 2017 -- I think it's now under Tools > Options > Projects and Solutions > Locations. – Chris R Jul 16 '18 at 16:56
1

Visual Studio 2017 changed the way it recognizes templates, I had problems with that as well.

Excerpt from Microsoft docs:

Previously, devenv /setup or devenv /installvstemplates scanned the local disk to find project and item templates. Starting in Preview 4, scanning will be performed only for the user-level location (%USERPROFILE%\Documents\My Exported Templates) that is used for templates generated by the File / Export Templates command.

For other (non-user) locations, you must include a manifest(.vstman) file that specifies the location and other characteristics of the template. The .vstman file is generated along with the .vstemplate file used for templates. If you install your extension using a .vsix, you can accomplish this by recompiling the extension in Visual Studio 2017. But if you use an .msi, you need to make the changes manually. For a list of what you need to do to make these changes, see Upgrades for Extensions Installed with an .MSI later in this topic.

If you need more information, you can take a look here: https://learn.microsoft.com/en-us/visualstudio/extensibility/upgrading-custom-project-and-item-templates-for-visual-studio-2017

And here are the steps to create new item templates: https://learn.microsoft.com/en-us/visualstudio/ide/how-to-create-item-templates

Excerpt to comply with SO's recommendations:

To add a custom project item template to the Add New Item dialog box

  1. Create or open a project in Visual Studio.
  2. Add an item to the project and modify it if you want to.
  3. Modify the code file to indicate where parameter replacement should take place. For more information, see How to: Substitute Parameters in a Template.
  4. On the File menu, click Export Template.
  5. Click Item Template, select the project that contains the item, and click Next.
  6. Select the item for which you want to create a template, and click Next.
  7. Select the assembly references to include in the template, and click Next.
  8. Type the icon file name, preview image, template name, and template description, and click Finish.

The files for the template are added to a .zip file and copied whatever directory you specify in the dialog. The default location is ..\Users\Documents\Visual Studio \My Exported Templates\ folder.

Warning

In earlier versions of Visual Studio, the default location is ..\Users\Documents\Visual Studio \Templates\ItemTemplates.

Hopefully it will be helpful.

eestein
  • 4,914
  • 8
  • 54
  • 93
  • 1
    The Export Template wizard behaves as advertised and generates the zip file, but VS 2017 doesn't add it to the Add New Item dialog even after restarting. Despite the promise in [this link](https://learn.microsoft.com/en-us/visualstudio/ide/how-to-troubleshoot-templates), there's no error message in the event log. – John Riehl Apr 25 '17 at 21:38
  • @JohnRiehl are you sure you followed all the steps mentioned there? And also that you're files are in the correct folder? For me it worked fine. – eestein Apr 25 '17 at 23:36
  • Positive. The only way I can get an item template to show up is to copy the included .cs and .vstemplate files from the installation directory to \Visual Studio 2017\Templates\ItemTemplates\Visual C#. It then shows up as a duplicate entry (e.g. if I copied Class.cs and Class.vstemplate, I would get two entries for Class). Unfortunately, I can't seem to change the name...edits to .vstemplate have no effect and changing the file names causes the item to disappear from the dialog. – John Riehl Apr 27 '17 at 11:58
0

None of the solutions or documentation on MSDN ended up working for me. What did work was clearing the item template cache for Visual Studio (I assume it then it forced to reload the templates).

Go to these two folders, navigate one beyond in the version of Visual Studio your using (it will have some random characters with the folder name) and then delete the contents of the ItemTemplate folders under that. After that I restarted Visual Studio (as an admin) and the templates started working.

  1. %appdata%\Microsoft\VisualStudio\
  2. %localappdata%\Microsoft\VisualStudio\
b.pell
  • 3,873
  • 2
  • 28
  • 39
0

For Windows 10 and Visual Studio 2017:

...\Documents\Visual Studio 2017\Templates\ItemTemplates\

...\Documents\Visual Studio 2017\Templates\ProjectTemplates\

E.g.:

C:\Username\Documents\Visual Studio 2017\Templates\
Grant Miller
  • 27,532
  • 16
  • 147
  • 165
0

The solution to this problem for me was so simple, that I couldn't find it anywhere online. I had the same issue where my item template just was not showing up in the Add > New Item... dialog, even though I followed all of the steps laid out.

The answer: make sure you don't have any illegal characters in your *.vstemplate file. In my scenario, the <Description> text had angled brackets in it, which of course are illegal characters in this context.

William Herrmann
  • 343
  • 2
  • 10
0

None of these solutions worked for me.

I was using the 'Export Template' wizard in Visual Studio, but for some reason the .vstemplate file being exported was missing <TemplateGroupID>AspNetCore</TemplateGroupID>.

Manually adding <TemplateGroupID>AspNetCore</TemplateGroupID> to the <TemplateData> section of my .vstemplate file after exporting it in Visual Studio fixed the problem for me.

Moo
  • 849
  • 7
  • 16
-1

Update all WINDOWS 10 Lastest Version And Visual Studio