CodeSmith Generator templates are plain text files that contain three different types of content:
- Directives to the CodeSmith Generator engine
- Static content that is copied directly to the template's output
- Dynamic content (programming code) that is executed by the CodeSmith Generator engine
The dynamic content in a CodeSmith Generator template can be written in C#, Visual Basic, or JScript. For this template, we'll use C# as the template scripting language. We can set the scripting language (C#, Visual Basic, JScript) in the CodeTemplate directive's language attribute as shown in the code sample below). For this template you can use the Generator Template Editor or notepad.
Every CodeSmith Generator template starts with a CodeTemplate directive. This directive tells CodeSmith Generator 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 CodeTemplate directive sample above defines three attributes (Language, TargetLanguage and Description).
- The TargetLanguage attribute specifies the language of the generated output.
- The Description attribute gives the purpose of the template.
With this single line of code saved as a file named AssemblyInfo.cst, you've got a CodeSmith Generator template. But it doesn't do anything yet.
Next: Start with the Result