Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install .NET 4.5 with a WiX bundle?

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?

like image 639
Torbjörn Bergstedt Avatar asked Nov 22 '12 13:11

Torbjörn Bergstedt


People also ask

How do I install a package on WiX?

Steps to Install WiX on Windows 11.1 and click on the download button. Step 2: You will be redirected to the source code present in the version control system GIT, and we need to choose the appropriate .exe file and click on download. Here we have chosen wix311.exe and click on it, and then it will be downloaded.

What is WiX bundle?

A WiX bundle is a software development kit that enables developers to create installer packages for the Windows platform. WiX bundles allow developers to create installers that are compliant with the Windows Installer technology.

Can I use C# in WiX?

The toolset includes a compiler, linker, archiver, librarian and several other tools to help create MSI and MSM packages. WiX is released under the GNU General Public License version 3.0 (GPLv3). PRO TIP: WiX is a toolset for building Windows installation packages from XML source code. It does not use C#.

What is WiX C#?

Introduction. Wix# is an open Source framework available on GitHub and used for generating Installer using C# syntax. Wix# is an open source framework for building installer setup for MSI source code by using script file that is written into C#. Wix# uses C# to produce a wix or MSI source code.


2 Answers

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.

like image 57
ChristianH Avatar answered Nov 15 '22 19:11

ChristianH


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.

like image 22
TheESJ Avatar answered Nov 15 '22 17:11

TheESJ