WiX Condition works in MSI but not in Bundle

0

When I'm building my MSI file, and I use a basic condition, the expected happens. For example, let's say that I have this in Setup File:

<Property Id="myProperty" Value="0"/>
<Condition Message="Value of myProperty is [myProperty], and it should be 1.">
    <![CDATA[Installed OR myProperty = "1"]]>
</Condition>

If I build this and run the MSI file, it works -- that is, it displays the error message and quits.

Working condition when running MSI

However, if I put the MSI into a Bundle, it doesn't work. That is, when I put just this into my Bootstrapper ("Properties" below is the name of my Setup project -- bad name, I realize):

    <Chain>
       <MsiPackage SourceFile="$(var.Properties.TargetPath)"/>
    </Chain>

And then I run the setup file, I get an error. When the installation starts, it checks the condition, gives me the expected message box (same as above), and then I get this error message:

Setup Failed

Looking at the Log, I get three error messages:

Error 0x80070643: Failed to install MSI package. 
Error 0x80070643: Failed to execute MSI package. 
Error 0x80070643: Failed to configure per-machine MSI package.

With the exit code:

Exit code: 0x643, restarting: No

I'm such a noob at WiX that I'm not even sure how to go about researching what the problem is -- I can't even ask an intelligent question. Hence, I'm reaching out to you kind folks!

(I'm using WiX 3.10 and Visual Studio 2015)

EDIT:

Thanks for getting back to me! I tried your suggestions:

In the installer file, I made the property public and I made it secure. I left the condition the same, and, since I don't think that I should get the value here as opposed to in the bootstrapper, I left the value of the property out. Here is the code that I made for the property/condition:

<Property Id="MY_PROPERTY" Secure="yes"/>
<Condition Message="MY_PROPERTY is [MY_PROPERTY].  Should be 1">
    <![CDATA[Installed OR MY_PROPERTY = "1"]]>
</Condition>

Then, in the boostrapper file, I added a child element of and gave it a value:

<MsiPackage SourceFile="$(var.LCondErrorInstaller.TargetPath)">
    <MsiProperty Name="MY_PROPERTY" Value="0"/>
</MsiPackage>

When I ran it, I got almost the same behaviour as I did before, except for one difference -- when I get the error message. This time, I get the pop-up screen with the Message condition and the same error message as I did before (see "Setup Failed" above), except this time I get it happens little later in the installation, making me think that the condition is, in fact, getting triggered in the bootstrapper.

As far as the log files, they look the same (I'm not sure how to get log files of the MSI when running the Burn file, what I do now is just run the Burn file with the flag "/l", like so: > file.exe /l logFile.log).

For clarity, here are the parts of the log file that appear to be important:

    Error 0x80070643: Failed to install MSI package.
    Error 0x80070643: Failed to execute MSI package.
    Error 0x80070643: Failed to configure per-machine MSI package.
    ...
    Exit code: 0x643, restarting: No

I should have been more specific when I initially asked the question about what kind of behaviour I'm looking for...

I will have more than just that one MSI file in the Burn file. What I want to do is this: when the Burn file installs, if there is a condition in one of the MSI files that is not met, I want that MSI file to simply not be installed, and the rest of the MSIs to be installed. I don't care about the UI.

If there's another way to do this, I'm all ears.

wix
windows-installer
bundle
asked on Stack Overflow Nov 17, 2016 by Bob • edited Nov 18, 2016 by Bob

1 Answer

2

If you have launch conditions in the MSI you can replicate or move those launch conditions into the bootstrapper bundle itself to stop this type of behaviour.

Launch condition failure returns Fatal Error 1603 (0x643 in hex) which is what I would expect to see when the MSI launched by the bootstrapper fails due to launch condition not met.

You should see something like this in the msi's logs

Action ended 17:33:38: LaunchConditions. Return value 3.
MSI (c) (08:4C) [17:33:38:610]: Doing action: FatalError
Action 17:33:38: FatalError. 
Action start 17:33:38: FatalError.
...
MSI (c) (08:4C) [17:33:41:188]: MainEngineThread is returning 1603


To elaborate, you would have to change your msi package definition to the following to get it to run properly through the bootstrapper

<Chain>
   <MsiPackage SourceFile="$(var.Properties.TargetPath)">
      <MsiProperty Name="MYPROPERTY" Value="1"/>
   </MsiPackage>
</Chain>

Additionally if you want to pass in a property from your bootstrapper to your MSI the property must be a public property which is a property whose name is ALL CAPS.

If you want to use this property somewhere in the Install phase of your msi you must also mark this property as secure.

answered on Stack Overflow Nov 17, 2016 by Brian Sutherland

User contributions licensed under CC BY-SA 3.0