Compiling the Template and Generating Code

At this point, the template is ready to use. Save the file, and then double-click it in Windows Explorer. This will open the template's property sheet. Fill in values for the template's properties and click the Generate button to build a new AssemblyInfo.cs file instantly:

There! Wasn't that easier than editing yet another file that Visual Studio .NET didn't build to your standards?

We chose this example to be a simple "Hello World" type template. How much time it would save you depends on how many new projects you create, of course. But this same technique - starting with the output you want to build, identifying the static content, making the content dynamic, and adding properties for the dynamic content - works with a wide range of code. You can build code for remoting and Web services, data access layers, standard user interfaces, and anything else you can imagine. CodeSmith lets you replace repetitive hand-coding with code generation. That's a powerful productivity booster that you'll wonder how you ever lived without.