Building, Running, and Compiling Templates

CodeSmith Generator allows you to build, run, and compile your templates.

Building Templates

To compile the current template, select Build from the Build menu, or press F6, or press Ctrl+Shift+B, or click the Build button on the toolbar. The Output window will show the results of the build operation.

Running Templates

To run the current template, select Run from the Debug menu, or press F5, or click the Run button on the toolbar. This will execute the current template, using values from the Properties window together with the template to create the generated code. At the end of the Run operation, CodeSmith Generator will display the generated code in a generated document.

Compiling Templates

 You can compile a template to an assembly (.dll file), which you can then reference from any .NET project. To compile a template to an assembly follow the steps below.

  1. Create or use an existing .NET 4.0 class library project.
  2. Add your master template to the project via the add new or add existing. You can also add the template as a linked item.
  3. Ensure the ClassName and Namespace attributes on the CodeTemplate Directive are set properly on your template.
  4. Right click the template you added to the project and select properties.
  5. Once the properties window is open, set the templates CustomTool to TemplateSourceGenerator.
  6. Build the project you created in step 1