Upgrading CodeSmith 2.x Templates
Although CodeSmith 5.x templates are almost 100% compatible with CodeSmith 2.x templates, there are a couple breaking changes that CodeSmith 2.x users should be aware of when upgrading. You may need to make minor changes to your CodeSmith 2.x templates to have them work perfectly in CodeSmith 5.x.
CodeSmith 5.x requires every template to have a CodeTemplatedirective. The CodeTemplate directive must be the first thing in the file, with the possible exception of template comments.
CodeSmith 2.x allowed you to use several formats for template comments that CodeSmith 5.x does not allow. In particular, these two formats are no longer accepted for template comments:
<% // some template header %> <%-- some comment %>
In CodeSmith 5.x, the only acceptable format for template headers and comments is as follows:
<%-- some template header -%> <%-- some comment -%>
Note that other formats are still valid when you want to include a comment in the generated source code. This is distinct from including a comment in the template that does not appear in the generated code. To generate a C# comment, you still use the format
<% // some C# comment %>
and to generate a VB comment, you still use the format
<% ' some VB comment %>
Although you can still programmatically compile sub-templates, it is more efficient to use the new Register directive instead.