.Net support notes
Since version 3.1, InstallMate supports the installation of .Net assemblies with the following features:
- A requirements check for the .Net runtime.
- Two variables (MsiNetAssemblySupport and VersionCLR) to check the .Net runtime version elsewhere in the project.
- Detection of .Net assemblies when you add new files to the project.
- An Assembly-type of component;
- Installation of both private and global assemblies (the latter into the GAC).
All this functionality is built into the installer; no external tools such as GACUTIL.exe are required.
Adding .Net assemblies to your project
The easiest way to add .Net assemblies to your InstallMate project is to add them as installation files. InstallMate will detect .Net assemblies and create separate assembly-type components for them with the required settings.
To add .Net assemblies manually, do the following:
- On the Components project page, create a new Assembly object.
- Set the Assembly type to either .Net, Private (for a private assembly) or .Net, Global (for global assemblies, see below).
- Click the ... (browse) button to the right of the Manifest file field and select the manifest file for the assembly.
- Add the installation file that contains the .Net manifest to the newly created assembly (right-click on the assembly object in the Components and Assemblies tree, then choose Add Object...).
- If necessary, add any further non-manifest files and other installation resources to the assembly in the same manner. Note that all files in the assembly must be installed in the same folder.
By default, assemblies are assumed to be private to your application; if you want register them as global assemblies, you must do the following:
- Ensure that all your assembly manifest files are signed and contain a public key or public key token. This is required to generate a strong name for the assembly.
- Install the assemblies in the GlobalAssemblyCache folder in your InstallMate project. You can find this folder as Target System\Windows\assembly.
- Set the Assembly type to .Net, Global.
InstallMate will produce a number of diagnostic warnings if you build a project that does not conform to these requirements. DO NOT IGNORE these warnings.
COM interop registration
There is no built-in support yet for COM interop registration. The recommended approach to register your .Net assemblies for backward compatibility with COM is as follows:
- Add the .Net assembly files to the InstallMate Builder project. This will detect the assemblies and create corresponding Assembly-Components for them.
- Separately, run regasm yourassembly.dll /regfile on each of the assemblies that require COM interoperability. You might want to add /codebase, but only if your assemblies are signed and contain a public key (or token).
- Back in InstallMate Builder, import the REGEDIT4 files produced by the previous step into your project. When asked, add them to the component that corresponds to the assembly to which they belong.
You can find the regasm.exe tool in the .Net installation folder on your system, typically C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 or something similar.
Detection of .Net
The simplest method of checking for .Net runtime support is to specify it as a System Requirement in your InstallMate Builder project. However, this simply prevents installation if the correct .Net version is not present on the system, without opportunity to install it.
An alternative method is therefore to NOT list .Net as a system requirement, but to use conditional actions to warn the user of a missing .Net runtime and/or to install it.
There are two variables that you can use in the conditions.
MsiNetAssemblySupport contains the dotted-decimal CLR version number, for example 1.1.4322.2032. You can use this one in conditional expressions like:
<$vercmp(<MsiNetAssemblySupport>, 1.1)> >= 0
VersionCLR contains the CLR version number encoded as 1000 * major + 10 * minor:
- .Net 1.0 = 1000
- .Net 1.1 = 1010
- .Net 2.0 = 2000
This one can be used more easily:
VersionCLR >= 1010