title: WiX 'Bundle' 'ExePackage' 'DetectCondition' is always false
body: <p>I am trying to create a WiX bundle that installs the .NET Framework 4.0 before my <a href="http://en.wikipedia.org/wiki/Windows_Installer" rel="nofollow">MSI</a> installer. I inspected the log file for my bootstrapper using the command line argument <code>\l log.txt</code> and discovered that the <code>ExePackage::DetectCondition</code> is always evaluating to false.</p>
  
  <p>I am including <code>WixNetFxExtension.dll</code> as a reference in my Visual Studio 2010 Windows Installer XML Bootstrapper project.</p>
  
  <p>I am including the <code>NetFxExtension</code> namespace:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
  </code></pre>
  
  <p>Providing the basic bundle framework:</p>
  
  <pre><code>  &lt;Bundle Name="RSA Bootstrapper"
        ...
      &lt;BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" /&gt;
        ...
  
      &lt;Chain&gt;
        &lt;PackageGroupRef Id="NET40" /&gt;
        &lt;PackageGroupRef Id="RSA_Application" /&gt;
      &lt;/Chain&gt;
    &lt;/Bundle&gt;
      ...
  </code></pre>
  
  <p>I am including the <code>&lt;PropertyRef Id="NETFRAMEWORK40FULL" /&gt;</code> in the fragment and then going on to define the ExePackage for .NET Framework 4.0 (<code>NET40</code>):</p>
  
  <pre><code>  &lt;Fragment&gt;
      &lt;PropertyRef Id="NETFRAMEWORK40FULL" /&gt;
      &lt;PackageGroup Id="NET40"&gt;
      &lt;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" &gt;
      &lt;ExitCode Value="0" Behavior="success" /&gt;
      &lt;ExitCode Value="1641" Behavior="scheduleReboot" /&gt;
      &lt;ExitCode Value="3010" Behavior="scheduleReboot" /&gt;
      &lt;ExitCode Behavior="error" /&gt; &lt;!-- Everything else is an error --&gt;
    &lt;/ExePackage&gt;
      ...
  </code></pre>
  
  <p>I have also checked the Visual Studio build output to confirm that the <code>WixNetFxExtension.dll</code> is referenced correctly:</p>
  
  <p>C:\Program Files (x86)\WiX Toolset v3.7\bin\Light.exe ... -ext "C:\Program Files (x86)\WiX Toolset v3.7\bin\WixNetFxExtension.dll"</p>
  
  <p>The problem is with the <code>DetectCondition</code> property. No matter what I set it to, it evaluates to <code>false</code>.</p>
  
  <p>Thinking that maybe the <code>NETFRAMEWORK40FULL</code> reference cannot be trusted, I tried using this instead:</p>
  
  <pre><code>&lt;Fragment&gt;
    &lt;Variable Name="isInstalled"
        Type="numeric"
        Value="0"
        Persisted="yes"
        bal:Overridable="yes"/&gt;
    &lt;util:RegistrySearch Id="FindInstallKey"
        Root="HKLM" Key="SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"
        Value="Install"
        Result="exists"
        Variable="InstallKeyExists" /&gt;
    &lt;util:RegistrySearch
        Root="HKLM" Key="SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"
        Value="Install"
        Variable="isInstalled"
        After="FindInstallKey"
        Condition="InstallKeyExists = true"
        Format="raw" /&gt;
  &lt;/Fragment&gt;
  </code></pre>
  
  <p>Setting <code>DetectCondition="isInstalled"</code> or <code>DetectCondition="isInstalled = true"</code> always evaluates to false. Even setting <code>DetectCondition="true"</code> always evaluates to false!</p>
  
  <p>Here is a log snippet of what I am talking about, with <code>DetectCondition="true"</code></p>
  
  <pre><code>[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 &gt;= 3)) OR ((VersionNT = v5.2) AND (ServicePackLevel &gt;= 2)) OR ((VersionNT = v6.0) AND (ServicePackLevel &gt;= 1)) OR (VersionNT &gt;= 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.
  </code></pre>
  
  <p>Specifically,
  <code>i052: Condition 'true' evaluates to false.</code>
  and actually <code>Condition 'NOT NETFRAMEWORK40FULL' evaluates to true.</code> 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 <code>HKLM\SOFTWARE\Wow6432Node</code> (I am on a 64 bit system).</p>
  
  <p>Am I missing something? Why doesn't DetectCondition work for me? The project compiles, runs, deploys the payload(s) and otherwise works fine.</p>