tags:

views:

1035

answers:

2

I am trying to put together a small 'prerequisites' dialog in Wix to give confidence to the users that they have all of the required things needed to run my software:

For example, I have a need for Managed DirectX, so I look for some DLLs:

<Property Id="MANAGED_DIRECTX">
  <DirectorySearch Path="$(env.SystemRoot)\Microsoft.NET\DirectX for Managed Code\1.0.2902.0" Depth="0" Id="MDXDir">
    <FileSearch Name="Microsoft.DirectX.dll"/>
  </DirectorySearch>
</Property>

<Property Id="MANAGED_DIRECTX_DIRECTINPUT">
  <DirectorySearch Path="$(env.SystemRoot)\Microsoft.NET\DirectX for Managed Code\1.0.2902.0" Depth="0" Id="MDXInputDir">
    <FileSearch Name="Microsoft.DirectX.DirectInput.dll"/>
  </DirectorySearch>
</Property>

I also have a CustomAction to combine my condition logic:

<CustomAction Id="SetManagedDirectXInstalled"
              Property="MANAGED_DIRECTX_INSTALLED"
              Value="NOT([MANAGED_DIRECTX] = '') AND NOT ([MANAGED_DIRECTX_DIRECTINPUT] = ''")/>

This CustomAction is sequenced:

<InstallExecuteSequence>
  <Custom Action="SetManagedDirectXInstalled" After="AppSearch" />
  <RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>

What I should now be able to do is use "MANAGED DIRECTX INSTALLED" to do something, e.g.

    <Control Id="NoManagedDirectX" Type="Text" X="20" Y="50" Width="300" Height="60" Transparent="yes" NoPrefix="yes" Hidden="yes">
      <Text>Microsoft Managed DirectX (MDX) for DirectX 9.0 is NOT installed</Text>
      <Condition Action="show">NOT MANAGED_DIRECTX_INSTALLED</Condition>
    </Control>
    <Control Id="ManagedDirectX" Type="Text" X="20" Y="50" Width="300" Height="60" Transparent="yes" NoPrefix="yes" Hidden="yes">
      <Text>Microsoft Managed DirectX (MDX) for DirectX 9.0 is correctly installed</Text>
      <Condition Action="show">MANAGED_DIRECTX_INSTALLED</Condition>
    </Control>

It doesn't matter what I do, the condition is always false (e.g. not installed) even when I know the files are there. Using the msiexec command with /l*vx does not show the MANAGED DIRECTX INSTALLED property anywhere.

When a <Condition> is used with the following, it successfully prevents installation (although I no longer want to block installs in this case, just advise).

<Condition Message="You must have Microsoft Managed DirectX (MDX) for DirectX 9.0 installed">
  MANAGED_DIRECTX AND MANAGED_DIRECTX_DIRECTINPUT
</Condition>

How can I trace/debug this (or what have I done wrong?)


EDIT - I'm now certain that my CustomAction is not even being called, setting it to the following is not showing expected results either!

<CustomAction Id='SetManagedDirectXInstalled'
              Property='MANAGED_DIRECTX_INSTALLED'
              Value='Something hard-coded'/>

or

<CustomAction Id='SetManagedDirectXInstalled'
              Error='Some error should show!'/>
+1  A: 

I think I may have found the answer, but I can't try it until I'm next at my development PC.

It appears I have to compare the values to TRUE/FALSE (or empty string) not just expecting it to work as boolean (Source)

In these expressions, you can use property names (remember that they are case sensitive). Non-existent property names will be treated as empty strings. The logical value of a property reflects whether it has been set—meaning that you cannot check for a logical value by simply using the property:

  • PROPERTY
    This will evaluate to true if the property has been set and has any value, even if this value is false.
  • NOT PROPERTY
    This will evaluate to true if the property has not been set at all.
  • PROPERTY = TRUE
  • PROPERTY = FALSE
    This is the proper way to check the value of a logical property.
Ray Hayes
A: 
  1. To debug, use a verbose log file. It will show you the states of your Properties as they change. You should then be able to evaluate the Condition with that knowledge

  2. I answered this same question not too long ago here. A Condition that uses the Property name is a test for existence. An existence test for a Property evaluates to true if the Property has any value at all. If you want to check the value of a Property you need to do so explicitly.

Rob Mensching
I'm running with the /l*vx command line argument but the CustomAction set property doesn't show!
Ray Hayes
I have tried adding the following, but it's still always blank (even though the two bits inside are not!Value="NOT ([MANAGED_DIRECTX] = "") AND NOT ([MANAGED_DIRECTX_DIRECTINPUT] = "")"
Ray Hayes
Even a CustomAction setting the property to [MANAGED_DIRECTX] (not-blank) and no attempt at boolean logic results in a blank property! Is the square-bracket convention correct?
Ray Hayes
I am not convinced at all that the CustomAction is ever being called, nothing mentions it in the log and I can see no side-effect of the call even if I simply put Value="Hello" !
Ray Hayes
Did you schedule the CustomAction in the appropriate sequence?
Rob Mensching
See the InstallExecuteSequence in the original question... that is, I think, how you schedule CA's isn't it?
Ray Hayes
Yes, but is it ending up in your MSI? At this point, I must admit, I'm very confused by what you are trying to do here. Looking very closely, it looks like you're trying to have a Property that contains characters commonly used in Conditions to be evaluated as Conditions. I don't think the Windows Installer works that way. But I can't explain why your CustomAction/@Error example doesn't work either. There isn't enough information in the text above to state for sure what the problem is now... I'm just guessing.
Rob Mensching

related questions