Monday, November 17, 2008

Merge modules and properties

As you know, you can expand the values of your MSI package’s properties—for example, in registry or INI data—at run time using [PropName] expressions. Something that’s a bit trickier is to use the values of properties that you’ve defined in a merge module.

The idea is that every merge module has a unique identifier, which is stored in the ModuleSignature table. (You can stop reading if you create merge modules by hand; this is useful only if your development environment hides these details.) An identifier looks like ModuleName.HHHHHHHH_HHHH_HHHH_HHHH_HHHHHHHHHHHH, where the HHHH_etc. number is a GUID with the curly brackets removed and the hyphens replaced with underscores. Many primary keys in your merge module database (your MSM file) are decorated with that .HHHH_etc. suffix, which means that component names, Registry-table keys, and (the reason we’re talking about this) Property-table and Directory-table keys have that quasi-GUID appended.

For example, suppose you have a property called MERGE_MODULE_PROPERTY defined in your merge module project. If you merge your merge module into a full MSI package and create a log file while deploying the MSI package, mixed in with the main MSI’s properties you’ll see entries that look like this:

Property(C): WindowsFolder = C:\WINDOWS\
Property(C): WindowsVolume = C:\
Property(C): VersionNT = 501

Therefore, if you want to expand the value of your merge module property at run time, you’ll need to use the [PROP.HHHHHHHH_HHHH_HHHH_HHHH_HHHHHHHHHHHH] format.

Moreover, if you see other log entries with that kind of suffix, the attached item probably comes from a merge module.

Note that the decorations go only one way: if your merge module uses undecorated [PROPNAME] somewhere, the property (if there is one) from the consuming MSI package will be expanded normally.

No comments: