I want to use an MSI installer property in a condition message in a WiX installer. This MSI property is set by a C++ custom action. I can set and get the same MSI property and value before calling the condition message, but it is failing when I use it in condition message.
My condition message is looks like
<CustomAction Id="CustomAction1" BinaryKey="CustomDLL"
DllEntry="CustomAction1" Execute="immediate" Return="check" />
<InstallUISequence>
<Custom Action="CustomAction1" Before="LaunchConditions">Not Installed</Custom>
</InstallUISequence>
<InstallExecuteSequence >
<Custom Action="CustomAction1" Before="LaunchConditions">Not Installed</Custom>
</InstallExecuteSequence>
<Condition Message="message comes here.">
<![CDATA[(MyProperty= "NO")]]>
</Condition>
Here this MyProperty is a string and returns either YES or NO, and it is set by C++ CA and this condition is failing in both cases. But I want to show this message only when the MyProperty is set to "NO".
So how do I use my custom MSI property in a condition message that was set by a custom action?
Best Answer
I would try to UPPERCASE the property
MyProperty
to make it a PUBLIC property, and then I would also declare it in your WiX source via a Property Element and set theSecure attribute
toYes
and see if that helps. The WiX markup:I would also retrieve the property after you set it in your C++ custom action to determine if it has been set correctly (it could be blank). Using VBScript you can retrieve the property very easily. Here is a sample (VBScript helps avoid any compilation and you can embed the source in the custom action - great for testing purposes - and use it only for testing purposes):
As a WiX element, something like this (can't test right now - give it a try - remember to insert in the
InstallUISequence
orInstallExecuteSequence
):I believe this should help you sort out what the problem really is.
You can use the WiX Property element to test the condition by hard coding a value outright (in case the C++ code set property call is the problem). The following should make your launch condition evaluate to false (triggering the message you specified to show):