Marc Dannemann
Marc Dannemann

Reputation: 103

Empty MSI property after adding value

Is there any special handling required when setting a property through a CustomAction provided by a merge module? I have two custom actions providing three properties to be used later within the merge module. They are set by usual C# code:

session["APPSRVPORT"] = port.ToString();

MSI log reports that the property has been set to a value:

MSI (s) (C0!DC) [11:58:04:615]: PROPERTY CHANGE: Adding APPSRVPORT property. Its value is '11376'.

When it comes to install the components, the following statement is used to install a registry value which uses the MSI property filled above:

<RegistryValue Name="AppSrvPort" Value="[APPSRVPORT]" Type="string" />

However, the log shows that the value is empty at this point:

MSI (s) (C0:AC) [11:58:06:208]: Executing op: RegAddValue(Name=AppSrvPort,,)

Can anybody tell me how to fix this? I've already checked, that the execute sequence is valid (i.e. setting the property comes before action "WriteRegistryValues")

Thanks in advance!

Upvotes: 1

Views: 642

Answers (1)

zett42
zett42

Reputation: 27786

When you reference a property in a .wxs script of a merge module, it will be modularized (i.e. having the merge module GUID appended). So the <RegistryValue> element will actually be interpreted like this:

<RegistryValue Name="AppSrvPort" Value="[APPSRVPORT.YOUR_MERGE_MODULE_ID]" Type="string" />

YOUR_MERGE_MODULE_ID will be the GUID of the merge module having - replaced by _, e. g. 1E35CFEB_7FA9_49F2_8E0D_5D941720EE81.

To fix the issue, you could either append the merge module ID when writing the property or suppress modularization.

Since you are using the property only within the merge module, I'd suggest the former to avoid accidentally overwriting any existing property of the main MSI that has the same name. Think of the merge module ID as the "namespace":

session["APPSRVPORT.YOUR_MERGE_MODULE_ID"] = port.ToString();

Suppressing modularization can be useful if a property is intended to be shared between the main MSI and the merge module:

<Property Id="APPSRVPORT" SuppressModularization="yes"/>

Note: Suppressing modularization will issue warnings CNDL1006 and CNDL1086 which can be ignored, if you know what you are doing. ;-)

Upvotes: 2

Related Questions