Number of downloads: 534 TutorialExamples.zip (37.98K)
Number of downloads: 534Overview
This tutorial will guide you through the basic steps needed to alter the VB.NET Windows forms application project template in VS2008. Once you feel comfortable with this simple modification you can do the same for other project templates.
There are a multitude reasons for altering a template, for instance you do not write new application much but instead work on one project for a long time then move to a new project. Usually developers writing a new windows form application have several mundane task to perform ranging from adding staple code modules, global exception handlers, menus etc. By selecting the default windows forms application template none of the above are there so we must manually complete these task.
A better solution is to have the default windows form template to have staple modules, global exception handlers, menus etc. done when selecting a new project.
- Find code modules you want to include into the modified template.
- Close VS2008
- Open the folder C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplatesCache\VisualBasic\Windows\1033
- Create a complete backup of the folder “WindowsApplication.zip” which can be done by renaming it to say “BACKUP_WindowsApplication.zip”.
- Create a new folder called “WindowsApplication.zip”
- Copy contents from “BACKUP_WindowsApplication.zip” into “WindowsApplication.zip”
- Copy files from step one into “WindowsApplication.zip”
- Open “windowsapplication.vbproj” with notepad
- Find the line <Compile Include="Form1.vb">
- Directly above you will see <ItemGroup>
- Between these two lines insert the modules using the example below. So you have a module named ConvertMethods.vb we add the following which includes a folder destination for the module. The folder will be created when using this template and the module will be placed into the folder. The folder name is your choice. Repeat this step for all modules, classes and other files you are including. <Compile Include="Extensions\ConvertMethods.vb" />
- To add references in simple locate the item group directly above step 9 and 10, grab the reference from another project by editing the project file in VS2008 and use it here.
- Save and close “windowsapplication.vbproj”
- Now locate “windowsapplication.vstemplate” and open it in notepad.
- In the copied line (using ConvertMethods.vb” as in step 11) change TargetFileName="My Project\AssemblyInfo.vb" to TargetFileName="Extensions\ConvertMethods.vb"
- Repeat step 16 for each added module followed by saving the file.
- Fire up VS2008 and create a new Windows forms application. If you followed the steps above your additions will be in the project. If not research what went wrong and correct it or simply close VS2008 and delete the folder “WindowsApplication.zip” and rename “BACKUP_WindowsApplication.zip” to “WindowsApplication.zip”. Restart VS2008 and you are back to the original template.
See attached WinZip for basic template and also a demo project showing additions to the default template in action. I kept the demo project simple for ease of learning.