user2357446
user2357446

Reputation: 676

Wix bootstrapper trouble detecting .net framework

I am trying to detect whether or not the .Net framework is installed on the client's computer before I install my application. If it isn't I include the installation file for it execute it.

I have the following code in my chain:

  <ExePackage Id="Net45" Name="Microsoft .NET Framework 4.5.1 Setup" Cache="no" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes"
    SourceFile="F:\Net Framework Install.exe"
    InstallCondition="NOT(Installed OR NETFRAMEWORK45)" />

And I also declare the following fragment:

  <Fragment Id="InstallConditionChecks">
    <PropertyRef Id="NETFRAMEWORK45"/>
  </Fragment>

Finally, I believe I am referencing all of the right wix libraries needed to detect the .net installtion:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
     xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">

The issue is thet even though I have a test machine that definitely has the .Net framework 4.5 installed, the installer still tries to install it (which leads to the .net installer trying to repair the installtion).

Am I doing something wrong here?

Upvotes: 1

Views: 1032

Answers (2)

Sean Hall
Sean Hall

Reputation: 7878

There's two issues here. The main problem is that PropertyRef is for MSIs, not bundles. You need to use a RegistrySearchRef. The other problem is that you're putting detection logic in InstallCondition, but that belongs in DetectCondition. Remove your InstallCondition and use the same DetectCondition that the NetFx extension uses: https://github.com/wixtoolset/wix3/blob/develop/src/ext/NetFxExtension/wixlib/NetFx451.wxs

<?define NetFx451MinRelease = 378675 ?>
<util:RegistrySearchRef Id="NETFRAMEWORK45" />
<ExePackage DetectCondition="NETFRAMEWORK45 &gt;= $(var.NetFx451MinRelease)" />

Upvotes: 2

CheGueVerra
CheGueVerra

Reputation: 7963

You don't check the registry of the target machine for the target framework you are looking for have a look at this tutorial, it will show you how to detect the Net Framework (RegistrySearch)and even shows how to make it work for Win32 or Win64.

Tutorial here

Upvotes: 0

Related Questions