Preprocessed templates are very cool (see this post). When I explained them to Karl Shifflett on the phone one day, once he got it he got excited and said “wow, this is just what I’ve been waiting for”. Preprocessed templates are very cool.
But, what if you don’t want to commit your entire development to Visual Studio 2010? What if you don’t want beta software on every dev machine. Preprocessed templates are part of Visual Studio. Ah, what to do?
Do what I do. Down target to 3.5.
The core concept of preprocessed templates is that when the custom tool runs you create a normal, normal, normal, normal .NET class that when run will produce your artifact (such as code). It’s a normal class (really). The custom tool runs either when you save, or when you explicitly run the tool. Take a look at the code so you understand the simplicity of what’s happening. But realize the specific code will change in Beta 2, so don’t get caught up by the current messiness.
You control the references and the project properties of this completely normal .NET class and assembly. You can set the target for this assembly to .NET 3.5. Every single thing you do in your development process, except the editing of templates and saving them, can be done in Visual Studio 2008 and .NET 3.5 (or potentially below, but LINQ is powerful in templates). You only need to have one boot or VPC in your organization that deals with the VS 2010 betas. I’m running it side by side on my dev box, but I would recommend you follow all the Microsoft warnings unless rebuilding systems is a favorite pastime.
Assuming you build the MEF preview against .NET 3.5, you can also use MEF in your templates.
This doesn’t mean you can directly use the “custom-tool-does-it-all” approach encouraged by VS 2008 (which is an approach I dislike). You still need a harness of some sort, and I really owe a blog post on that. But I’m heading to Nepal so it may be a while. In the meantime, perhaps one of the custom tool geeks can create a custom tool that knows how to run preprocessed templates, possibly through MEF. Oh, dear, that’s another post…and really, I need to pack… you would not want me to forget slippers…