Create the template

CodeSmith Generator templates are plain text files that contain three kinds of content:

  • Directives to the Generator engine.
  • Static content that's copied directly to the output.
  • Dynamic content (code) that Generator runs when it generates.

You can write the dynamic content in C#, Visual Basic or JScript. This template uses C#.

Create the file

Create a file named AssemblyInfo.cst. You can use the Template Editor or any text editor.

Tip

To create the template in Visual Studio with the Template Editor, select File > New > File, select the CodeSmith Generator category, then select Generator Template (CSharp).

Add the CodeTemplate directive

Every Generator template starts with a CodeTemplate directive, which tells Generator some basic facts about the template. Add this line to the file:

<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Create an AssemblyInfo.cs file." %>

This directive sets three attributes:

Attribute What it sets
Language The language of the code inside the template. Valid values are C#, VB and JavaScript.
TargetLanguage The language of the generated output.
Description A description of the template's purpose.

Save the file. With this one line, you have a Generator template, although it doesn't generate anything yet.

Next: Start with the result