1

A similar post is up here but I cant get mine working WiX Bundle bal:condition - util:RegistrySearch variable always false

Sir, I am struggling get this exact thing working. "Version" is set to 0 when Registry key is absent and to 1 when key is present. Either cases my bundle still gets installed.

I am using VS 2015 and Wix 3.10. Pls can you help.

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
 xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
 xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">  
 <Bundle Name="XXX"
      Version="XXX"
      Manufacturer="XXX"
      UpgradeCode="XXX"
      IconSourceFile="XXX"
      Copyright="XXX" >

<util:RegistrySearchRef Id='SearchForMyIns' />

<BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost">
  ...
</BootstrapperApplicationRef>

<Chain>
  <PackageGroupRef Id='NetFx40Web' />

  <MsiPackage SourceFile="$(var.DummyInstaller.TargetDir)\DummyInstaller.msi"  DisplayName="Dummy Conditioning" />      
</Chain>
</Bundle>

<Fragment>
<util:RegistrySearch
      Id='SearchForMyInst'
      Variable="Version"
      Result="exists"
      Root="HKLM"
      Key="SOFTWARE\MyInst" 
      Win64="yes" />
<bal:Condition Message="ThirdParty Application Required.">Version</bal:Condition>
</Fragment>

</Wix>
Community
  • 1
  • 1
sai
  • 23
  • 3

2 Answers2

1

The Bal:Condition doesn't evaluate if you are using MBA. Check the following link

http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Wix-Burn-Bundle-condition-does-not-work-if-using-MBA-td7581757.html

Change

<BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost">

to

<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">

You will see Bal:Condition working

Kamal Deka
  • 148
  • 1
  • 14
0

The reason this is always installing for you is that

<bal:Condition Message="messagehere">Version</bal:Condition>

will evaluate the existance of Version not the value of Version. Since your registry search is on exists, Version is always defined and thus the condition always passes. (I believe this is because all registry search variables are implicitly string variables)

If you add "Version = 1" then your installation should only continue when your registry search does find what you're looking for.

I would also like to point out a particularly nasty pitfall of this type of condition. What happens if a user installs your bundle then decides they don't need your bundle or the third party program anymore and they uninstall them both but they uninstall the third party program first?

Your installer will be unable to uninstall because when it tries to run it will fail the bal:Condition every time since the third party program is no longer present on the system.

To solve this behaviour you should add "OR WixBundleInstalled" to your bal:Condition.

Brian Sutherland
  • 4,698
  • 14
  • 16