Referencing Assemblies

You can use the Assembly directive to reference an external assembly from a template, or to include a source file for dynamic compilation. For example, CodeSmith Generator ships with an assembly named CodeSmith.CustomProperties.dll that includes custom editors for file names and string collections. If you'd like to use one of these editors from your own template's property sheet, you need to reference the assembly:

<%@ Assembly Name="CodeSmith.CustomProperties" %>

The source code for the CustomProperties assembly is in the Sample folder (E.G., Documents\CodeSmith Generator\Samples\<Version>\Projects\CSharp\CustomPropertiesSample) of your CodeSmith Generator installation.

All transitive dependencies must also be referenced.

Assembly Directive Attributes

There are two attributes that you can supply to the Assembly directive. You must supply one or the other, but not both.

Name

The Name attribute specifies the file name of an assembly to reference from the current template. The assembly must exist in the Global Assembly Cache, in the same directory as CodeSmith, in the CodeSmith\bin directory, in the CodeSmith\AddIns directory, or you can specify a path relative to the template location. If you're working with templates within CodeSmith Generator, the preferred location is the CodeSmith\AddIns directory.

You can also specify the Assemblies FullName (E.G., ExampleAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)
Src

The Src attribute specifies the relative path to a source file that should be dynamically compiled along with the template.

Path

The path attribute is a directory path to the assembly being used.