4

I was damned to build an setup using wix and wixtoolset 3.11. Yes, its the hell. Doing simple things with this toolset and reading the manual consumes much time and money.

My goal: The setup should download and install the .NET Framework 4.5. Here is the declaration:

<?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:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
  <?include ApplicationData.wxi?>
    <Fragment>
      <WixVariable Id="NetFx45WebInstallCondition" Value="" Overridable="yes" />

      <!-- install dotnet framework -->
      <!-- https://stackoverflow.com/questions/42720958/web-download-of-vcruntime140-with-wix-burn/42726779 -->
        <PackageGroup Id="NetFx45Web">
        <ExePackage
          InstallCommand="/q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx45FullLog].html&quot;"
          RepairCommand="/q /norestart /repair /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx45FullLog].html&quot;"
          UninstallCommand="/uninstall /q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx45FullLog].html&quot;"
          PerMachine="yes"
          Id="NetFx45Web"
          Cache="yes"
          Permanent="yes"
          Vital="yes"
          Protocol="netfx4"
          DownloadUrl="https://www.microsoft.com/de-ch/download/confirmation.aspx?id=30653"
          DetectCondition="false"
          Compressed="no"
          InstallCondition="!(wix.NetFx45WebInstallCondition)"
          Name="Framework\dotNetFx45_Full_setup.exe"
          />
      </PackageGroup>
  </Fragment>
</Wix>

I do not want to embed any .NET Framework installer into my setup, but for whatever reason, one of the attributes 'Name' or 'SourcePath' is required. Either I use the attribute 'SourcePath' or 'Name', both declarations need a path to an existing file. Yes, of course, thats true. That´s Wix.

When I use 'SourceFile' to a path, then the compiler in Visual Studio runs successful, but on the target system, where the DotNet Framework 4.5 is not installed, nothing happens. No Framework will be installed. Okay, then I tried the attribute 'Name' instead and passing the value 'Framework\dotNetFx45_Full_setup.exe'. When compiling the setup, I get the following error:

The system cannot find the file 'SourceDir\Framework\dotNetFx45_Full_setup.exe'

Hmm... What the hell is SourceDir, why do I need to delcare a path either I want that the setup downloads the file? Many questions, but let´s begin with the first one:

How can I fix the problem regarding the misterious 'SourceDir'?

ouflak
  • 2,458
  • 10
  • 44
  • 49
Simon
  • 4,157
  • 2
  • 46
  • 87

1 Answers1

2

You should replace the PackageGroup element with a PackageGroupRef element.

http://wixtoolset.org/documentation/manual/v3/xsd/wix/packagegroupref.html

You will need to add a reference to the NetFxExtension ( WixNetFxExtension.dll ) because the extension provides this definition at build time. You can do this in Visual Studio / Votive by adding a reference to the project or by adding it to your light.exe call. See:

http://wixtoolset.org/documentation/manual/v3/customactions/wixnetfxextension.html

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:bal="http://schemas.microsoft.com/wix/BalExtension" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
  <Bundle Name="ProductName1" Version="1.0.0.0" Manufacturer="ProductName1" UpgradeCode="f6ac65f9-56ca-496c-b04c-b68b37967298">
    <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
      <bal:WixStandardBootstrapperApplication LicenseFile="Resources\EULA.rtf" LogoFile="Resources\Icon.png" />
    </BootstrapperApplicationRef>
    <Chain>
      <PackageGroupRef Id="NetFx45Web"/>
      <MsiPackage Id="ProductName1" SourceFile="$(var.ProductName1Setup.TargetPath)" />
    </Chain>
  </Bundle>
</Wix>
Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • Just replacing the PackageGroup element does not work, because the PacakgeGroup element is a child of PackageGroup. As you can see in the 4th line of my declaration, the WixNetFXExtension is already used. A reference to from the PackageGroupRef to 'NetFx45Web' does not trigger any download. This answer is wrong. – Simon Apr 23 '18 at 10:39
  • The answer isn't wrong, you just didn't understand it. I added a snippet to show you a working example. – Christopher Painter Apr 23 '18 at 13:03
  • I have added your snipped into my Project and nothing happens when I execute the msi setup on the target system. The setup still not downloads the .NET Framework. – Simon Apr 23 '18 at 13:15
  • when you say "msi setup" was does that mean to you? Did you run a .exe or a .msi? Have you logged it and read the log file? – Christopher Painter Apr 23 '18 at 14:01
  • We build an msi setup with wix. – Simon Apr 23 '18 at 14:19
  • 1
    So that might be the source of your misunderstand. An MSI can't install the .NET framework. You have to create a "bootstrapper" (.EXE). The EXE runs first, installs the .net framework and then installs your MSI. – Christopher Painter Apr 23 '18 at 14:33
  • Ahh okay - that´s it. Thank you for your support. – Simon Apr 24 '18 at 06:28