12

I need to include Microsoft .NET 4.5 as a prerequisite with my installation bundle, and I want it as automatic as possible. However, .NET should not be removed when unistalling. I think I have read just about everything on how to use DetectCondition and/or InstallCondition, but I'm still not getting it right; it is either always running the .NET installation, or never running it.

Here's my latest setup:

<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'>

  <!-- Define minimum .NET Framework version -->
  <?define NetFx45MinRelease = 377811?>
  ...
    <Chain>
      <PackageGroupRef Id="Netfx45FullPackage"/>
      ...
    </Chain>

    <PackageGroup Id="Netfx45FullPackage">
      <ExePackage Id="Netfx45Full" Cache="no" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes"
                  SourceFile="..\..\..\..\Environment\InstallerResources\Prerequisites\dotnetfx45_full_x86_x64.exe"
                  InstallCommand="/passive /norestart"
                  DetectCondition="NETFRAMEWORK45 &gt;= $(var.NetFx45MinRelease)"
                  InstallCondition="NOT REMOVE AND (NETFRAMEWORK45 &lt; $(var.NetFx45MinRelease))" />
    </PackageGroup>

(For some reason, I had to define NetFx45MinRelease myself even though it should have been included with WixNetFxExtension.)

How can I get the settings correct?

woderkant
  • 31
  • 5
Torbjörn Bergstedt
  • 3,359
  • 2
  • 21
  • 30
  • ?define directive is per-file. So you should include it in every file which uses it. That's why you were forced to redeclare it. – Sasha Nov 26 '12 at 10:29

2 Answers2

11

I'm not quite sure why you're having problems, but I just had the same task, and it (now ;-) works as intended. That is, it installs .NET 4.5 only if required, and won't do a .NET uninstall when uninstalling the bootstrapper as a whole.

However, .NET 4.5 can be uninstalled individually, which I think is good.

This is what I used (most probably derived from other Stack Overflow posts):

<PackageGroup Id="Netfx45Xxx">
    <ExePackage Id="Netfx45Xxx" Cache="no" Compressed="no" PerMachine="yes" Permanent="yes" Vital="yes" InstallCommand="/q"
        SourceFile="C:\wixtest\dotnetfx45_full_x86_x64.exe"
        DetectCondition="(Netfx4FullVersion=&quot;4.5.50709&quot;) AND (NOT VersionNT64 OR (Netfx4x64FullVersion=&quot;4.5.50709&quot;))"
        InstallCondition="(VersionNT >= v6.0 OR VersionNT64 >= v6.0) AND (NOT (Netfx4FullVersion=&quot;4.5.50709&quot; OR Netfx4x64FullVersion=&quot;4.5.50709&quot;))"/>
</PackageGroup>

The strange thing is that you already have Permanent="yes", which indeed is key to keeping .NET on uninstall.

One difference is that I have no explicit "NOT REMOVE" in the InstallCondition, maybe that is more confusing than helpful to Windows Installer...?

I am using WiX 3.7.1224.0, which currently is the latest.


One comment to TheESJ's answer: even with the predefined PackageGroupRef, you can supply a local file to avoid downloading. Simply place it in a "redist" folder below your bootstrapper EXE file, and it will be taken from there if present without downloading. I found this behaviour yesterday via the log file after a faulty install.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ChristianH
  • 126
  • 3
  • Thanks! I actually use a similar (now working :) setup, I think I'll tweak my `InstallCondition`to use your setup. – Torbjörn Bergstedt Jan 16 '13 at 13:04
  • 10
    what is the context of ? What file is it in? Is it contained in a tag or something else? The WiX documentation for this stuff is poor and this answer doesn't paint the whole picture. – Stealth Rabbi May 03 '13 at 13:07
  • 2
    Would be nice to see the entire example of how this works together. – C.J. Dec 20 '16 at 16:51
5

You shouldn't need to define the PackageGroup. This is contained in WixNetFxExtension. See http://wix.sourceforge.net/manual-wix3/install_dotnet.htm. All you need to do is include a reference to WixNetFxExtension in your wixproj, then add the PackageGroupRef to one of the PackageGroups documented here: http://wix.sourceforge.net/manual-wix3/wixnetfxextension.htm to your chain.

TheESJ
  • 2,357
  • 17
  • 13
  • I'm aware of that option, the reason we're doing like this is to have full control over what is installed and to allow installtaion on machines with no internet access. – Torbjörn Bergstedt Nov 29 '12 at 07:40
  • 8
    Always better to show how, than to tell what to do.... Some of us are very new to Wix (Like only have a few hours of experience). – C.J. Dec 20 '16 at 16:51
  • Also the fx package does not work with burn bootstrappers, great for msi not so much for exe – Paul Swetz May 14 '19 at 15:52
  • old question but curious because I am trying to install .net dependencies as simple as possible. So you are saying does not work with bootstrapper? @PaulSwetz – Todilo Nov 28 '19 at 07:05