Flexible Project Templates

Topics: ASP.NET MVC, General
Apr 28, 2013 at 11:58 PM
Ideally, a project template system should have these characteristics:
  • Easy to create: OSS projects (and anyone else) should be able to easily create project templates that can stand on equal footing with the in-the-box ASP.NET templates.
  • Easy to combine: If I create an ASP.NET MVC project, I should be able to independently choose a database access layer, an IoC container, a view engine, a unit testing framework, etc. Each of those choices should correspond to a different template, which all work together to create the final project. Of course, this should work equally well with other frameworks, so I can (for example) create a Fubu or ServiceStack project that uses Entity Framework, Autofac, Spark, and MSTest.
  • Easy to change: Once I've created a project, I should be able to go back and change my choices. For example if I didn't choose to include IoC or unit testing, or if I want to change from Entity Framework to NHibernate, I should be able to go back and make those changes. This encourages experimentation and discoverability of alternatives.
It would be difficult to change the existing system of project templates in Visual Studio to support this. But we don't need to! Instead of Visual Studio templates, we can create NuGet packages that add the "project template" code for each component, and which work well together when they are mixed and matched.

Then the new project dialog could be changed to offer a nice UI to choose which component of each type to use, and to install the appropriate template NuGet packages based on what was selected. The dialog could also be invoked on an existing project to add or change choices.

There are probably some challenges around how to get the different packages to work together, but they are certainly solvable. If need be, we can add functionality to NuGet itself to help out with this.

In addition to providing a better project creation experience, this is one way we, as a community, can help promote OSS projects and foster a healthy .NET OSS ecosystem.