Files included in an add-in

An add-in may be composed by several assemblies and data files. Those files must be declared in the main assembly using custom attributes, or in the XML manifest.

It is important to properly declare all files used by an add-in. For example, when a type from the add-in is required (e.g. an ICommand implementation), only properly declared assemblies will be checked. This information is also used by setup tools to know exactly what needs to be packaged when creating an add-in package.

Declaration using custom attributes

Assemblies can be included using the Mono.Addins.ImportAddinAssembly attribute, and data files using Mono.Addins.ImportAddinFile:

[assembly:ImportAddinAssembly ("AdditionalAssembly.dll")]
[assembly:ImportAddinAssembly ("SupportLibrary.dll", Scan=false)]
[assembly:ImportAddinFile ("SomeData.xml")]

The Scan property can be set to false in [ImportAddinAssembly] attributes to specify that the included assembly has to be ignored by the add-in scanner (so it won't be considered for importing extensions or extension points). The default value is true.

Declaration using an XML manifest

File and assembly imports are declared inside the Runtime element:

<Addin 	namespace="TextEditor" id="Core" version="1.0" isroot="true">
		<Import assembly="TextEditor.exe" />
		<Import assembly="TextEditorLib.dll" />
		<Import file="license.txt" />
		<ScanExclude path="SomeLib.dll" />
		<ScanExclude path="someDirectory" />

The following table describes the attributes and elements shown above:

XML Description
/Addin/Runtime Contains the list of files.
/Addin/Runtime/Import/@assembly Declares that an assembly belongs to the add-in.
/Addin/Runtime/Import/@file Declares that a file belongs to the add-in.
/Addin/Runtime/ScanExclude Declares that a file or directory must be ignored by the add-in scanner.

Notice that an assembly can be imported using the Import element and at the same time excluded from the scan using ScanExclude. This is useful when the assembly doesn't contain any add-in declaration, but it is still needed since it implements some add-in logic.

Last edited May 10, 2010 at 11:33 PM by slluis, version 1


No comments yet.