Microsoft 9GD00001 Computer Accessories User Manual


 
Chapter 12: Customizing the Development Environment 343
Creating New Project Templates
If you’re working on a single project that lasts a long time, you might be satisfied with
using a default template and doing a one-time modification. However, if you are starting
new projects on a regular basis, customizing a project template can be very useful. There
are various reasons you might want to create a custom project template, such as adding
new items that aren’t included in the default project template, removing items from
the default template that you don’t ever use, or changing an existing item for version
upgrades. In addition to customizing existing templates, you might want to create a brand
new template for a new project type that doesn’t yet exist.
The example in this section will show you how to customize the ASP.NET MVC
project template. The specific changes made to the template will be to remove much of
the default code provided by the template. The assumption is that once you’ve written a
few ASP.NET MVC applications, you won’t need the default files as examples and would
prefer to start with a more bare-bones template and build the application from the ground
up yourself.
Modifying a Project
The easiest way to get started with creating a new project template is to start a new project
that is most similar to the project type you want to create. If you wanted a blank project,
you might start with a Console project because there aren’t many items and it’s quicker to
delete them all. In the scenario for this section, we want to create a specialized ASP
.NET
MVC project, so it makes sense to create a new ASP.NET MVC project. The following
steps show you how:
1. Press CTRL-SHIFT-N to create a new project and select ASP.NET MVC 2 Web Application.
Name the project and solution Custom ASP.NET MVC Web Application and set the
location for anywhere you like. Click OK to create the project. Next, the Create Unit
Test Project window will appear and you should click “No, do not create a unit test
project” and click OK. VS will create a new solution with a project. Chapter 9 explains
what each of the projects and items are.
2. Open the Controllers folder and delete its contents.
3. Open the Models folder and delete its contents.
4. Open the Views folder but only delete the Account and Home folders.
5. Open the Shared folder, under the Views folder, and delete its contents.
6. Double-click Global.asax and comment out the call to routes.MapRoute in the editor.