I am using Wix as my installer and a C# project which contains the custom Actions.
I want to install a Utility if it's not already installed but skip the installation of it if it already exists on the system (through registry check).
C# Custom action:
[CustomAction]
public static ActionResult CheckForUtilityInstallation(Session session)
{
var UtilityKey = Registry.LocalMachine.OpenSubKey(...);
if (UtilityKey != null)
{
var value = UtilityKey.GetValue("DisplayVersion");
session.Log("Utility installation found! Version: {0}", value);
session["UTILITYINSTALLATIONEXISTS"] = "1";
}
else
{
session.Log("Utility installation not found!");
session["UTILITYINSTALLATIONEXISTS"] = "0";
}
return ActionResult.Success;
}
If the utility exists, the parameter UTILITYINSTALLATIONEXISTS is passed with parameter 1 otherwise with parameter 0.
The Wix code is this:
<CustomAction Id="InstallUtility" FileKey="filAAF554748D18441299BE9AEFA324AA76" ExeCommand="/noicons /nofeedback /verysilent /components=Entity" Return="ignore" Execute="deferred" Impersonate="no" />
<CustomAction Id="CheckUtilityInstallation" BinaryKey="CActions.CA.dll" DllEntry="CheckForUtilityInstallation" Return="check"/>
<InstallExecuteSequence>
<Custom Action="CheckUtilityInstallation" Before="InstallUtility" />
<Custom Action="InstallUtility" Before="InstallFinalize">UTILITYINSTALLATIONEXISTS = "0"</Custom>
</InstallExecuteSequence>
Somehow the UTILITYINSTALLATIONEXISTS parameter is not passed from the Custom Action C# code to the Wix installer thus avoiding to install the Utility in any case.
What am I doing wrong?
Log file:
Calling custom action CActions!CActions.CustomActions.CheckForUtilityInstallation
Utility installation not found!
MSI (s) (54!C0) [11:26:32:917]: PROPERTY CHANGE: Adding UTILITYINSTALLATIONEXISTS property. Its value is '0'.
Action ended 11:26:32: CheckUtilityInstallation.2D89DF12_B7E5_454A_A3A4_884A776A78D1. Return value 1.
MSI (s) (54:64) [11:26:32:932]: Skipping action: InstallUtility.2D89DF12_B7E5_454A_A3A4_884A776A78D1 (condition is false)