WiX 'Bundle' 'ExePackage' 'DetectCondition' is always false

Terrabits picture Terrabits · Feb 13, 2013 · Viewed 11.6k times · Source

I am trying to create a WiX bundle that installs the .NET Framework 4.0 before my MSI installer. I inspected the log file for my bootstrapper using the command line argument \l log.txt and discovered that the ExePackage::DetectCondition is always evaluating to false.

I am including WixNetFxExtension.dll as a reference in my Visual Studio 2010 Windows Installer XML Bootstrapper project.

I am including the NetFxExtension namespace:

<?xml version="1.0" encoding="UTF-8"?>
<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"
    xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">

Providing the basic bundle framework:

  <Bundle Name="RSA Bootstrapper"
      ...
    <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
      ...

    <Chain>
      <PackageGroupRef Id="NET40" />
      <PackageGroupRef Id="RSA_Application" />
    </Chain>
  </Bundle>
    ...

I am including the <PropertyRef Id="NETFRAMEWORK40FULL" /> in the fragment and then going on to define the ExePackage for .NET Framework 4.0 (NET40):

  <Fragment>
    <PropertyRef Id="NETFRAMEWORK40FULL" />
    <PackageGroup Id="NET40">
    <ExePackage SourceFile="dotNetFx40_Full_x86_x64.exe"
        Compressed="yes"
        Cache="yes"
        DetectCondition="NETFRAMEWORK40FULL"
        InstallCommand="/norestart /passive /showrmui /ACTION=Install"
        Permanent="yes"
        InstallCondition="NOT NETFRAMEWORK40FULL"
        Vital="yes" >
    <ExitCode Value="0" Behavior="success" />
    <ExitCode Value="1641" Behavior="scheduleReboot" />
    <ExitCode Value="3010" Behavior="scheduleReboot" />
    <ExitCode Behavior="error" /> <!-- Everything else is an error -->
  </ExePackage>
    ...

I have also checked the Visual Studio build output to confirm that the WixNetFxExtension.dll is referenced correctly:

C:\Program Files (x86)\WiX Toolset v3.7\bin\Light.exe ... -ext "C:\Program Files (x86)\WiX Toolset v3.7\bin\WixNetFxExtension.dll"

The problem is with the DetectCondition property. No matter what I set it to, it evaluates to false.

Thinking that maybe the NETFRAMEWORK40FULL reference cannot be trusted, I tried using this instead:

<Fragment>
  <Variable Name="isInstalled"
      Type="numeric"
      Value="0"
      Persisted="yes"
      bal:Overridable="yes"/>
  <util:RegistrySearch Id="FindInstallKey"
      Root="HKLM" Key="SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"
      Value="Install"
      Result="exists"
      Variable="InstallKeyExists" />
  <util:RegistrySearch
      Root="HKLM" Key="SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"
      Value="Install"
      Variable="isInstalled"
      After="FindInstallKey"
      Condition="InstallKeyExists = true"
      Format="raw" />
</Fragment>

Setting DetectCondition="isInstalled" or DetectCondition="isInstalled = true" always evaluates to false. Even setting DetectCondition="true" always evaluates to false!

Here is a log snippet of what I am talking about, with DetectCondition="true"

[16A0:17B4][2013-02-13T13:01:43]i001: Burn v3.7.1224.0, Windows v6.1 (Build 7601: Service Pack 1), path: C:\Users\lalic\Documents\Visual Studio 2010\Projects\RSA Preset\Bootstrapper\bin\Release\Bootstrapper.exe, cmdline: '/l log.txt -burn.unelevated BurnPipe.{33090847-CC78-445B-BAAA-564B840B7E8E} {38F95C6A-EC0F-4402-951B-FABFC5827CB6} 6296'
[16A0:17B4][2013-02-13T13:01:43]i000: Setting string variable 'WixBundleLog' to value 'C:\Users\lalic\Documents\Visual Studio 2010\Projects\RSA Preset\Bootstrapper\bin\Release\log.txt'
[16A0:17B4][2013-02-13T13:01:43]i000: Setting string variable 'WixBundleOriginalSource' to value 'C:\Users\lalic\Documents\Visual Studio 2010\Projects\RSA Preset\Bootstrapper\bin\Release\Bootstrapper.exe'
[16A0:17B4][2013-02-13T13:01:43]i052: Condition '((VersionNT = v5.1) AND (ServicePackLevel >= 3)) OR ((VersionNT = v5.2) AND (ServicePackLevel >= 2)) OR ((VersionNT = v6.0) AND (ServicePackLevel >= 1)) OR (VersionNT >= v6.1)' evaluates to true.
[16A0:17B4][2013-02-13T13:01:43]i000: Setting string variable 'WixBundleName' to value 'RSA Bootstrapper'
[16A0:17B4][2013-02-13T13:01:43]i100: Detect begin, 2 packages
[16A0:17B4][2013-02-13T13:01:43]i052: Condition 'true' evaluates to false.
[16A0:17B4][2013-02-13T13:01:43]i103: Detected related package: {D431417D-F0AC-4CFB-8E25-E27F5B8101D9}, scope: PerMachine, version: 2.1.15.0, language: 0 operation: MajorUpgrade
[16A0:17B4][2013-02-13T13:01:43]i101: Detected package: dotNetFx40_Full_x86_x64.exe, state: Absent, cached: None
[16A0:17B4][2013-02-13T13:01:43]i101: Detected package: RSA_Preset.msi, state: Absent, cached: None
[16A0:17B4][2013-02-13T13:01:43]i199: Detect complete, result: 0x0
[16A0:17B4][2013-02-13T13:02:04]i200: Plan begin, 2 packages, action: Install
[16A0:17B4][2013-02-13T13:02:04]i052: Condition 'NOT NETFRAMEWORK40FULL' evaluates to true.

Specifically, i052: Condition 'true' evaluates to false. and actually Condition 'NOT NETFRAMEWORK40FULL' evaluates to true. even though I have .NET 4.0 Full installed and can manually find the .NET 4.0 entry in my registry, both in the usual spot and under HKLM\SOFTWARE\Wow6432Node (I am on a 64 bit system).

Am I missing something? Why doesn't DetectCondition work for me? The project compiles, runs, deploys the payload(s) and otherwise works fine.

Answer

Bob Arnson picture Bob Arnson · Feb 14, 2013

<PropertyRef Id="NETFRAMEWORK40FULL" /> is a reference to an MSI property but you're creating a bundle. Bundles have variables that are distinct from MSI properties, though Burn itself provides a number of bundle variables that mimic those that MSI provides.

That said, WixNetFxExtension provides package groups for the 4.0 NetFx installers. You can replace all that with a simple <PackageGroupRef Id="NetFx40Redist" />.