Welcome to MSDN Blogs Sign in | Join | Help

jfo's coding

adventures in windows forms and wpf
Plugging in your own templates to Create New Project and Add Item

I wanted to let you all in on a trick I've been using for creating my test projects.

If you open up VS 2005, a new menu item has snuck on to the File menu:  "File->Export Template".  If you're always adding in the same sets of files into your project and changing a whole bunch of text, there are two options for the kinds of templates you can create:

Project template:   Plugs into the "Create New Project" dialog.
Item template:  Plugs into the "Add New Item" dialog.

You can put in replacement parameters in your files to represent stuff that might change (like safeprojectname, GUID, machinename, etc).

When you want to share the templates, it's pretty easy.  They wind up being .zip files that show up on the hard disk.  In my case, I just took

C:\...\My Documents\Visual Studio 2005\My Exported Templates\WindowsApplication24.zip

And made sure that it was in

C:\...\My Documents\Visual Studio 2005\Templates\ProjectTemplates

If you want to have different versions for different languages, you can move the template in the "Templates" directory to "Visual Basic" or "C#", etc folders.

You can also keep the templates in a central location.

More information

The basics:
Instructions for exporting a template
How to share your templates with others

Tweaking your template:
More details on the different kinds of templates and what's inside
More details on the replacement parameters
What's allowed inside a .vstemplate file

 

 

Posted: Sunday, May 14, 2006 12:11 PM by jfoscoding

Comments

Jason Haley said:

# May 14, 2006 1:57 PM

Jason Black said:

It's a shame that the template exporter can't handle exporting a multi-project solution.  I basically spent all day last tuesday fighting with trying to create a "starter kit" from such a multi-project solution (a solution with a GUI half that buids the exe, and a DLL half with generic, non-UI-specific code).

It's similarly a shame that the documentation for creating more interesting templates/starter kits isn't more robust.  The docs leave a hell of a lot to guesswork, and are not nearly complete in their descriptions of the .vstemplate and .vscontent schemas, as far as what tags are allowed where, and what the unwritten naming reqirements are.

In the end, I never could get it to work.  The .VSI installer I created claimed to install properly, but my starter kit was never visible from the file->new project dialog.

Any pointers to more information on debugging starter kit installation issues?
# May 15, 2006 3:13 PM

jfoscoding said:

Unfortunately, the menu items and the help are the extent of my knowledge in the area.

The Visual Studio Extensibility MSDN forum looks like a great place to start digging deeper...

http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=57&SiteID=1
# May 17, 2006 12:51 AM

Jay Kimble -- The Dev Theologian said:

Yesterday I was working for my demos for CodeCamp Tampa (yep, I’m finally speaking somewher), and...
# June 29, 2006 11:29 AM
New Comments to this post are disabled
Page view tracker