The easiest way to build a CodeSmith template is to start with an example of the code that you want to generate - in this case, a finished AssemblyInfo.cs file. Here's one that we'll use as we move through this tutorial:
using System.Reflection;
using System.Runtime.CompilerServices;
//
// Created: Friday, November 06, 2009
// Author: Blake Niemyjski
//
[assembly: AssemblyTitle("User storage utility")]
[assembly: AssemblyDescription("Helps manage data in Isolated Storage files.")]
[assembly: AssemblyConfiguration("Retail")]
[assembly: AssemblyCompany("MegaUtilities, Inc.")]
[assembly: AssemblyProduct("StorageScan")]
[assembly: AssemblyCopyright("Copyright (c) 2009 MegaUtilities, Inc.")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0")]
[assembly: AssemblyDelaySign(true)]
When you're looking at the file that you want to generate, you need to break the file up into three different types of content:
...
Note: Although we're not using the capability in this example, CodeSmith templates can easily contain conditional logic. For example, you could prompt the user for a value for the AssemblyDelaySign attribute, and then include additional attributes in the template's output if they set that attribute to true.
Next: Static Content in the Template