Referencing assemblies

Use the Assembly directive to reference an external assembly from a template, or to compile a source file together with the template.

For example, CodeSmith Generator ships with CodeSmith.CustomProperties.dll, which contains property editors for file names and string collections. To use one of these editors in your template's property grid, reference the assembly:

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

Note

Reference every assembly that your referenced assembly depends on, too.

The source code for CodeSmith.CustomProperties is in the samples folder: Documents\CodeSmith Generator\Samples\<version>\Projects\CSharp\CustomPropertiesSample.

Attributes

Supply either Name or Src, not both.

Attribute Description
Name The assembly to reference. See Where Generator looks for an assembly. For assemblies you use with templates, the AddIns folder is the preferred location. You can also give the assembly's full name, for example ExampleAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.
Src The relative path to a source file to compile along with the template.
Path The folder to look for the assembly in. Applies only with Name. A relative path is resolved from the template's folder.

To use the types in an assembly without fully qualifying their names, also import their namespaces.

Where Generator looks for an assembly

Generator searches for the assembly you give in Name in this order:

  1. The Path folder and its bin subfolder. Without Path, the template's own folder and its bin subfolder.
  2. The Generator install folder and its bin, AddIns and SchemaProviders folders.
  3. The .NET Framework folders and the Global Assembly Cache.