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:
- The
Pathfolder and itsbinsubfolder. WithoutPath, the template's own folder and itsbinsubfolder. - The Generator install folder and its
bin,AddInsandSchemaProvidersfolders. - The .NET Framework folders and the Global Assembly Cache.