Click here to Skip to main content
Click here to Skip to main content

Write Templates for Visual Studio 2010

By , 21 Jun 2010
 

Title Slide

Introduction

This article is part of my series on Visual Studio Extensions. Before you read it, please read the Introduction. It tells you the purpose of the series and gives you some tips on presenting my material. This article is designed to give you what you need to deliver a successful presentation. The speaker notes and demo script, along with the videos, are part of the package, and you won't learn everything from just the text of the article. My goal is to increase developer awareness of Visual Studio Extensions by making it easy for anyone to deliver a presentation on them at a user group, code camp, or the like.

Developers use project and item templates almost every day - creating new projects and adding items to existing projects. If they think about how those templates came to be, they probably assume it's a very difficult task suitable only for experienced developers, perhaps those on the Visual Studio team. This presentation aims to show that the very opposite is true. Anyone can create a project or item template. Whether it's to use yourself, to share with the team, or to share with the wider community, template creation is so quick and easy that you will save back the creation time the very first time you use it.

Presenting this session

This is a 300 level session for people who are comfortable with Visual Studio and have created plenty of projects. There are three demos, and because they have strong similarities, you need to work to keep it all straight for your attendees. I've recorded the demos and included links to them here so that you can see how it's all done. Once you know how to do these demos, you'll find the slides very easy to talk to since many of them just recap information from the demos. I do have speaker notes indicating what you can say to each slide. The demos take about half of a 75 minute slot, so you will have some time to talk to the slides.

Demo 1 - Item Template

This demo has a simple text file with boilerplate text in it that you might want to add as a new item to a variety of projects. You don't have to write any code, but you do have to drag things in and out of zip files and not get lost in a set of folders with very similar names. It's 9 minutes long.

Demo 2 - Project Template

Here, we make a project template from a project that has had a little customization applied. Like the item template, it's deployed by copying the zip to a magic folder, but towards the end, you can see that this approach is really a little fragile. This sets us up for the final demo. It's 13 minutes long, so I had to split it into two parts to upload.

Demo 3 - Deploying the Template

This demo continues from the previous one by showing how to deploy that template in a much safer and more robust way. It relies on an extension from Microsoft that simplifies building a VSIX dramatically. In fact, creating and using the VSIX is so simple you might miss it. This demo starts with showing you the gallery, then installs the extension right from inside Visual Studio. In no time, we re-export the template as a VSIX this time, and use it. Then, to round out the package, we put an icon, preview, and welcome page into the VSIX too. This is something everyone should do when they make a template. It's almost 16 minutes long, so I had to split it into two parts to upload.

Speaker Tips

Your goal for people leaving this session is that they see how simple it is to export a template and will create some of their own item and project templates to use in the immediate future. Some of them should also be planning to share those templates with team members. As well, if the Visual Studio Gallery is new to any attendees, they should be impressed by how easy it is to install useful extensions, and ready to take a look around and find some that they might like.

The Notes

Remember, you don't have to learn these just from the videos. There are detailed speaker notes and a demo script for you in the downloads for this article.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

KateGregory
Canada Canada
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5memberkuanyong26 Nov '12 - 16:16 
Simple, and come with very good description. Easy to understand.
GeneralMy vote of 1 [modified]memberArnaud Dovi2 May '12 - 5:34 
Videos are just too boring to follow and even if you speak, spoken English is much more difficult to understand than written
If people wants videos tutorials, Youtube suffice to itself
Found the article I should have found here http://msdn.microsoft.com/en-us/magazine/cc188697.aspx[^]

modified 2 May '12 - 11:50.

QuestionCan VSIX do what vstemplate can?memberEric Wahner8 Mar '12 - 4:47 
My question being that in the vstemplate I can use $safeprojectname$ within the template to have it name files based upon the project name. Since you have to edit the vstemplate in order to do that and the vsix file is more or less encrypted I don't see a way to do this.
GeneralExcellent work and fantastic high quality videos!memberFrank Heimes1 Jul '11 - 23:23 
Just what I needed to make my own project templates.
Much easier than reading through all the M$ manuals.Thumbs Up | :thumbsup:
QuestionC++ Project TemplatesmemberKerem Kat22 Jun '11 - 8:23 
You cannot create C++ project templates with this method. To create a C++ Project template, you can use Custom Wizards.
GeneralA project template bugmemberjmertus30 Jan '11 - 2:27 
You might want to mention a bug in the VS2010 project template that I had the misfortune of encountering.
 
Just create a project from Class Library and call it like Stupid. Create a project from Class Library and call it "Stupid With Spaces". Export and load these project templates.
 
Now create two new projects, one based on the "Stupid" template, say Duh, and another based on the "Stupid with Spaces" template say Huh.
 
Now look at the properties/Assembly name for these two projects. The Duh one will have Duh as the project name, the Huh one will have "Stupid with Spaces".
 
It appears that assembly names are not properly translated if they have spaces in the original template. This seems true in both VS2010 RTM and VS2010 SP1
 
Thanks for the videos, enjoyed them
 
-jam
GeneralCreate project dialogmemberjhegedus28 Nov '10 - 15:22 
Very nice tutorial. Thanks for you hard work. How do you control where the project template shows up in the create project dialog when you create the VSIX?
GeneralRe: Create project dialogmemberjhegedus28 Nov '10 - 15:23 
Oops. Looks like someone else already asked that question. Sorry about that.
Yeah whatever...

GeneralGreat tutorial!memberJalla Tjalabais30 Jul '10 - 2:15 
Hi, thanks for the enlightening vids! One question though: when using the VSIX wizard my C# templates only shows up under the C# category, how can I get to show under the Windows for C# folder?
Dominic Akadimah

GeneralRe: Great tutorial!memberKateGregory30 Jul '10 - 2:22 
I haven't been able to do that with the wizard. Instead I made a new VSIX, added the zip that already has NumberOfParentCategoriesToRollUp in its manifest to the project, then clicked Add Content and added the zip with (this is very important) the SUBFOLDER at the bottom of the dialog filled out as Windows. Then it appears both places.
 
I used this article as the starting point for the templates section in my Pluralsight course so you can see it in action at the on demand course[^]. Maybe use the free trial they have to take a look at the Deploying Templates section. It covers exactly this.
GeneralRe: Great tutorial!memberJalla Tjalabais30 Jul '10 - 2:38 
Thanks for the quick reply! I will check thi out!
GeneralRe: Great tutorial!memberdeadlydog26 Aug '11 - 7:33 
After posting this same question on the MSDN Forums, I found somebody asking it here too. Hopefully I'll get a better work around than having to add all of the zip files as files instead of directly referencing the item template projects.
GeneralThanksmemberdevnet24721 Jun '10 - 19:11 
Hi,
I have watched your videos and I learned a couple of things I didnt know thank you.
 
It would be great if you did a couple of videos of more advanced features like IWizard and debugging them.
Or create a multiproject template where you can assign the name of the project.
thanks again.
thanks a lot

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 21 Jun 2010
Article Copyright 2010 by KateGregory
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid