Lately, I’ve been thinking about ways to manage and re-use existing code. Right away I thought of code snippets. Snippets are handy for methods or small segments of code, but what I was really looking for was a faster way to repurpose common class libraries and patterns.
Functionality such as caching, logging, abstracting the SharePoint data layer, etc. are a few examples of what tend to be boilerplate code. It would be great to have a pre-defined “Base” project that can be repurposed (and improved over time) to help speed up SharePoint development.
One way to achieve this is by creating a custom Visual Studio 2012 Project Template. Visual Studio provides a painless process to make this happen. And automatically handles the parameterization of namespaces for you.
Here’s a quick set of instructions to walk you through the process:
Step 1: Find an existing project or create a new one that you would like to use as a template. In this example I called mine “SharePoint.Base”.
Step 2: Export as a template. File –> Export template.
Step 3: Save as Project template.
Step 4: Select Template Options. I named my template “SharePoint Class Library”.
Step 5: Create a new project based on your template.
That’s it! You now have a custom template that can be modified to meet your development needs.