In my previous article I have explained how to create templates
in VS 2003. Many users might have noticed it required too much work and the
developer also needed to know how all different files come together and how to
use JavaScript to create the project. Now the developers can relax since in VS
2005 it takes only 5 steps to create a template.
Steps to create Project Templates in VS 2005
·
Start with a pre-defined template.
·
Make your changes, like adding forms, classes, etc.
·
Save the Project.
·
Click File -> Export Template Option.
·
The Wizard will walk you through creating the Project Template.
Please note: Some
users might not see the Export Template option in their File Menu. You might
need to add that option by following these steps.
·
Right Click on the toolbar and select Customize.
·
Click on the Commands tab.
·
Under Categories, select File.
·
Under Commands Select Export Template and drag the command under
File Menu.
To demo the project
template creation, I have created a website called templatearticle. The folder
structure looks like the following.
Figure 2
To create the
Project Template from the above structure, follow these steps.
·
Click File -> Export Templates.
·
The Export Template Wizard displays the below figure.
Figure 3
·
Choose Template Type Step has the following options.
·
The Project dropdown will display all the projects currently in
the solution. In this example we just have one project. So, only that project
is displayed in the dropdown.
·
For Language it will display all the different language options
available. In our case it should display Visual C#, Visual Basic and Visual
J#. I will select Visual Basic for this example, but in normal cases you would
select both Visual Basic and Visual C#.
·
If you wanted to export an item, you would select the Item Template
option. This option is explained in the next section.
·
Click Next.
·
The Select Template Options step displays the following.
Figure 4
·
The options for this step are the following.
·
Template Icon - You can select the image you want to display with
your template in the new Project dialog box.
·
Template Name - This is the name that will be displayed in the
New Project dialog box. For this example I have entered Template Article
·
Template Description - This will be displayed as description on
the New Project dialog box.
·
Automatically import the template into Visual Studio - This
option will store the template in the directory you have selected in your
options dialog box (explained earlier). If you uncheck this option then it
will store the template on the directory, shown above in the image. Once the template
is created you can simply copy the template to the folder from where your
templates are being picked for display.
·
Display an explorer window on the output files folder - This
option will display the folder in explorer window where the zip file for the
template is stored.
·
Click Finish.
·
Based on the options you have selected, the template that will be
created. It will also display the folder in explorer window if you have
selected the option of explorer window on the output files folder.
·
If you check your templates folder, the above options will create
a zip file. If you look inside the zip file, now you will see a vstemplate
file. You can open the vstemplate file and see all the options exported while creating
this template. Also, please note that the zip file contains one extra file
called _TemplateIcon.ico. This Icon will be used in the New Project / Item
dialog box.