In my previous article I covered the absolute basics of how to work with Visual Studio Templates. At the point you should be able to crank out either an item template or a project template. Now I’m going to talk about organizing your templates so they show up the way you want them to in your environment.
The basics
When you export a template and then put it in your “My Templates” folder, it shows up like this:
Which is pretty cool. However, notice that I had to scroll down past all the other stuff. You could change the sort order value to 10 and then copy your template in to Visual Studio’s cache. Doing so will cause your template to show up before everything else. If you leave the template in your “my templates” folder the sort order has no affect – VS sorts those templates alphabetically by Name. Sorry.
So changing sort order and moving in to VS’s template area causes things to look like this:
Better. But how do we get our template to show up in those folders under “Visual C#” or better yet: How do I make my own folder? Turns out to be really simple: create a folder. In the spirit of full disclosure, in order to get my template to show up at the very top under “Visual C#”, I had to create a 1033 folder under the CSharp folder (<VSInstall>\Common7\IDE\ProjectTemplates\CSharp). I’m not sure it that was because I’m screwing around with stuff or something else. Don’t really care now because I figured it out.
Anyway, what if I have a pile of templates that I want to organize together in my own subfolder? Create a subfolder, create a locale under it and then put your templates there. For instance I’ll create a “Jake’s Templates” folder and move my template there:
Pretty fickin cool. So know we know that we can make our templates show up wherever we want or even give them their own place.
Go forth and make templates!