Labels

Friday, April 4, 2008

Creating Re-Usable Project and Item Templates with VS 2005

Hi,

This blog post summarizes how we can fasten the WSP creation by creating & using Templates. The templates can of two types viz. Project Templates & Item Templates.

For using the templates, required is to create them and save them at ‘C:\Documents and Settings\Arunm.XP\My Documents\Visual Studio 2008\My Exported Templates\<Template Name>.zip.

The templates allows you to capture your personal coding preferences and default project items and encapsulate them in re-usable templates that you can quickly use when starting a new project or adding a new item to it. This can both save you a lot of manual time, as well as ensure on new projects that everything is setup exactly the way you like them.

Project Templates:

· Listed in the "My Templates" section of your "Create New Project" or "Create New WebSite" dialog box.

· Allow you to specify the initial set of files (and their layout and content), assembly references, and other preferences when you create a new project.

Item Templates:

· Listed in the "My Templates" section of your "Add New Item" dialog box.

· Allow you to create a customized template that you add new files to a project.

Features:

· You can name each Project and Item template using a descriptive name, and have any number of them that you want in VS 2005.

· You can also use ‘Built-In Macro Replacement Tokens’ to customize things like names, namespaces, paths, date/times, etc.

· You can also easily publish them and share them with others -- allowing you to easily distribute them across a team or your own community of friends.

Steps to Create Project Template:

In breif creating project template is very simple. Follow step as below.

· As normal process, create a website.

· Add contents into it. Add those contents which you want to add in all the projects. For E.g Images, XML, CSS folders, BasePage etc.

· Save it.

· Choose File – Export Template. This will open below dialog.












· Select Project Template. Click Next.

· This will open one more dialog where you can specify default icon, output location and few more. Then click Finish.

Once saved these project templates will be listed in the "My Templates" section of your "Create New Project" or "Create New WebSite" dialog box.

Steps to Create Item Template:

In breif creating Item template is same as project template. The only difference is - Item template is created for one item at a time.

· As normal process, create a website.

· Add contents into it. Add a single or multiple contents which you want to add in all the projects. For E.g Base Page, Defualt.aspx, Resx file.

· Save it.

· Choose File – Export Template. This will open same dialog as above. Select Item Template. Click Next.

· This will open one below dialog and will show one or multiple items depending on whehter you want to add single or multiple Items.

· But there is a catch here. As said above the checkboxes below are mutulally exclusive, i.e you can choose only one item to add.











· Select Item and Click Next. This will open one more dialog where you can add references. Skip it and click next.

· This will open one more dialog where you can specify default icon, output location and few more. Then click Finish.

Once saved these Item templates will be listed in the "My Templates" section of your of your "Add New Item" dialog box.

Hope this helps.

Thanks & Regards,

Arun Manglick Tech Lead +91 20 30230500 Ext: 620 +91 9850901262

No comments:

Post a Comment