Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

To  You can compile a template , select Compile To Assembly from the Tools menu. This will open the Compile to Assembly dialog box:

Image Removed

Fill in an assembly name, namespace name, and type name, and click OK to create the assembly. CodeSmith Generator will output a .dll an assembly (.dll file), which you can then reference from any .NET project. You will then be able to create an instance of your compiled template by using the type name that you specified. You can then set the properties on the template via code and call the Render or RenderToFile methods to execute the template. 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