HOW TO build your own Project Template in Visual Studio 2008

If you build a lot of websites that follow a similar structure or wish to enforce a similar structure within your team so that the code and applications are consistent and standardized, you can consider building your own Project template in Visual Studio 2008 in order to re-use. For instance, you may want the jQuery libary to be included in a JS folder for every new website that you create. Just like you see "ASP.NET Web Site" & other templates when you choose File > New option, you can have a custom Project Template show up after you create a new Project template.

The Visual Web Developer MSDN blog has detailed step by step instructions on creating a custom Project template for Visual Studio Web Developer & VSTS. I adapted the steps described there to create a Project template for VS 2008. Here are the instructions paraphrased for VS 2008:
  1. Open the model website based on which you wish to create newer websites.
  2. From the File menu, select Export Template...
  3. In the Export Template Wizard that appears, choose Project Template and click the Next button
  4. Choose a template name and specify a description for it.
  5. Keep the checkboxes "Automatically import the template into Visual Studio" and "Display an Explorer window on the output files folder" checked. (If you want your template to appear for all users, you should first un-check Automatically import the template into Visual Studio) and click on the Finish button of the Wizard.
  6. Copy the template (.zip file) alongside the other Project templates in this folder - Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\Web\CSharp\1033
  7. Select Visual Studio 2008 Command Prompt from Visual Studio Tools that appears in the Programs menu under Microsoft Visual Studio 2008.
  8. Run Devenv /setup at the command prompt
Now when you start creating a new website, you can select your new custom template.

Similarly, you can create an Item Template so that whenever you select File > New > File... or right click on a project within Solution Explorer & choose "Add New Item...", you can find a custom Item template similar to Web Form or AJAX Web Form.

Comments