0

WiX first timer here.

I am building an installer for my product using WiX, and I am attempting to validate that MSMQ is installed before continuing the installation, following this SO answer. I am using a Condition element, defined like this:

  <Condition Message="MSMQ must be installed in order to proceed.">
    <![CDATA[MSMQ_INSTALLED<>"false"]]>
  </Condition>

My Property and RegistrySearch look like this:

  <Property Id="MSMQ_INSTALLED" Value="false" Secure="yes">
    <RegistrySearch Id="Msmq.RS"
                    Root="HKLM"
                    Key="SOFTWARE\Microsoft\MSMQ"
                    Name="Values"
                    Type="raw"/>
  </Property>

But it never evaluates properly. The installation stops with the message, regardless that the Registry Key does exist. So my questions are:

  1. Am I using the Condition element correctly?
  2. What have I defined incorrectly in the evaluation?

On further testing, I have found that the MSMQ_INSTALLED property contains the value "1: 0 2:", regardless of the Registry Key that I search for, either existing or fake.

EDIT: The Condition element exists inside the Product element; that is an important distinction as the Condition element is overloaded.

EDIT: Modified Condition to use CDATA directive, and invert Inner Condition logic, to more accurately reflect issue.

Community
  • 1
  • 1
grefly
  • 1,181
  • 2
  • 12
  • 28
  • Not sure why this was downvoted - leave me a comment if I can clarify or disambiguate this post. – grefly Aug 11 '11 at 17:39

2 Answers2

1

Well, the answer was on SO the whole time. Apparently, searching for a Registry Key is not supported out of the box with WiX, so I created a Custom Actions project and used the Binary tag to import it into my MSI, then run the Custom Action at the appropriate spot during the install. In my case, it was before LaunchConditions.

For reference, the code is:

public class CustomActions
{
    [CustomAction]
    public static ActionResult CustomAction1(Session session)
    {
        session.Log("Begin CustomAction1");

        var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MSMQ");
        session["MSMQ_INSTALLED"] = key == null ? "-1" : "1";

        return ActionResult.Success;

    }
}

(The only class in the Custom Actions project)

<Binary Id="WixCustomAction" SourceFile="C:\work\RelayMed\src\dev\WixCustomAction\bin\Debug\WixCustomAction.CA.dll"/>
<CustomAction Id="CheckMsmq" BinaryKey="WixCustomAction" DllEntry="CustomAction1" Execute="immediate" Return="check"/>

(The import of the Binary into WiX, under the Product node.)

<InstallUISequence>
  <Custom Action="CheckMsmq"
          Before="LaunchConditions"/>
</InstallUISequence>

(The running of the Custom Action before LaunchConditions)

The Condition and the Property remained the same from the original post. The RegistrySearch was removed completely.

EDIT: Noted removal of the RegistrySearch tag.

Community
  • 1
  • 1
grefly
  • 1,181
  • 2
  • 12
  • 28
0

Your authoring says "if HKLM\SOFTWARE\Microsoft\MSMQ@Values has the literal value 'false', then the install can continue."

Just use "MSMQ_INSTALLED" to check for any string found in the registry value.

Bob Arnson
  • 21,377
  • 2
  • 40
  • 47