Building, Running, and Compiling Templates
In the CodeSmith Generator Template Editor you can build a template to check it for errors, run it to generate code, or compile it into an assembly.
Building a template
To compile the current template, press F6 or Ctrl+Shift+B, or click Build on the toolbar. The Output window shows the result of the build, and any problems appear in the Error List.
Running a template
To run the current template, press F5 or click Generate on the toolbar. Generator combines the values in the Properties window with the template and shows the generated code in a generated document.
Compiling a template to an assembly
You can compile a template into an assembly (.dll) and reference it from any .NET project.
- Create a .NET Framework class library project, or use an existing one.
- Add your master template to the project, either as a new or existing item or as a linked item.
- Make sure the
ClassNameandNamespaceattributes of the template's CodeTemplate directive are set correctly. - In Solution Explorer, right-click the template and select Properties.
- Set the template's Custom Tool property to
TemplateSourceGenerator. For more about this custom tool, see Viewing the compiled template source code. - Build the project.