Creating the Template
CodeSmith templates are plain text files that contain three different types of content:
- Directives to the CodeSmith engine
- Static content that is copied directly to the template's output
- Dynamic content (programming code) that is executed by the CodeSmith engine
The Professional Edition of CodeSmith includes CodeSmith Studio, a full-featured IDE for writing templates, but you can use any text editor to create a template. The dynamic content in a CodeSmith template can be written in C#, Visual Basic, or JScript. For this template, we'll use C# as the template scripting language.
Every CodeSmith template starts with a CodeTemplate directive. This directive tells CodeSmith some basic facts about the template. Here's the CodeTemplate directive for this template:
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Create an AssemblyInfo.cs file." %>
The Language attribute specifies the scripting language that will be used within the template itself. The TargetLanguage attribute specifies the language of the generated output. The Description attribute gives the purpose of the template; this string is displayed by CodeSmith Explorer and CodeSmith Studio as a tooltip for the template.
With this single line of code saved as a file named AssemblyInfo.cst, you've got a CodeSmith template. But it doesn't do anything yet.
Next: Start with the Result