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 "[WixBundleName]" /log "[NetFx45FullLog].html""
RepairCommand="/q /norestart /repair /ChainingPackage "[WixBundleName]" /log "[NetFx45FullLog].html""
UninstallCommand="/uninstall /q /norestart /ChainingPackage "[WixBundleName]" /log "[NetFx45FullLog].html""
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'?
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>