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 >= $(var.NetFx45MinRelease)"
InstallCondition="NOT REMOVE AND (NETFRAMEWORK45 < $(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?
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="4.5.50709") AND (NOT VersionNT64 OR (Netfx4x64FullVersion="4.5.50709"))"
InstallCondition="(VersionNT >= v6.0 OR VersionNT64 >= v6.0) AND (NOT (Netfx4FullVersion="4.5.50709" OR Netfx4x64FullVersion="4.5.50709"))"/>
</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.