WIX has NetFxExtension with NetFx4XXXX packages, so .NET Framework 4.6, for example, can be installed with the single line of code:
<?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="My App"> ... <BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost"> <Payload SourceFile="$(var.MySetupUI.TargetPath)"/> <Payload SourceFile="$(var.MySetupUI.TargetPath).config"/> <Payload SourceFile="$(var.MySetupUI.TargetDir)BootstrapperCore.dll"/> <Payload SourceFile="$(var.MySetupUI.TargetDir)BootstrapperCore.xml"/> <Payload SourceFile="BootstrapperCore.config"/> <Payload SourceFile="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceProcess.dll"/> <Payload SourceFile="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Configuration.Install.dll"/> <Payload SourceFile="C:\Program Files (x86)\WiX Toolset v3.11\SDK\Microsoft.Deployment.WindowsInstaller.dll"/> </BootstrapperApplicationRef> <Chain> <PackageGroupRef Id='NetFx46Web'/> <MsiPackage SourceFile="$(var.MyAppSetup.TargetPath)" Id="InstallationPackageId" Cache="yes" Visible="no"/> </Chain> </Bundle> </Wix>
But there is no package for .NET Framework 3.5 SP1, there are only properties like NETFRAMEWORK35…, so to check .NET Framework 3.5 SP1 I tried the following code:
<?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="My App"> ... <Chain> <PackageGroupRef Id='MbaPrereq'/> <MsiPackage SourceFile="$(var.MyAppSetup.TargetPath)" Id="InstallationPackageId" Cache="yes" Visible="no"/> </Chain> </Bundle> <Fragment> <WixVariable Id="WixMbaPrereqPackageId" Value="MbaPrereq" /> <WixVariable Id="WixMbaPrereqLicenseUrl" Value="License.rtf" /> <PropertyRef Id="NETFRAMEWORK35"/> <PropertyRef Id="NETFRAMEWORK35_SP_LEVEL"/> <Condition Message="This application requires .NET Framework 3.0 SP1. Please install the .NET Framework then run this installer again."> <![CDATA[Installed OR (NETFRAMEWORK35_SP_LEVEL and NETFRAMEWORK35_SP_LEVEL and NOT NETFRAMEWORK35_SP_LEVEL = "#0")]]> </Condition> <PackageGroup Id="MbaPrereq"> <ExePackage Id="MbaPrereq" Cache="no" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes" SourceFile="readme.txt" DetectCondition="1" /> </PackageGroup> </Fragment> </Wix>
MbaPrereq is a fake package that is used to define required variable WixMbaPrereqPackageId somehow. It is not clear what is the point of this WixMbaPrereqPackageId, and what if there are no required packages?
BootstrapperCore.config used with .NET 4.6 specifies version=”v4.0″ like in App.config:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <sectionGroup name="wix.bootstrapper" type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.BootstrapperSectionGroup, BootstrapperCore"> <section name="host" type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.HostSection, BootstrapperCore" /> </sectionGroup> </configSections> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" /> </startup> <wix.bootstrapper> <host assemblyName="MyApp"> <supportedFramework version="v4\Full" /> <supportedFramework version="v4\Client" /> </host> </wix.bootstrapper> </configuration>
BootstrapperCore.config used with .NET 3.5 SP1 specifies version=”v2.0.50727″, so probably it should look like this:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <sectionGroup name="wix.bootstrapper" type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.BootstrapperSectionGroup, BootstrapperCore"> <section name="host" type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.HostSection, BootstrapperCore" /> </sectionGroup> </configSections> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v2.0.50727" /> </startup> <wix.bootstrapper> <host assemblyName="MyApp"> <supportedFramework version="v3.5" /> </host> </wix.bootstrapper> </configuration>
At least there is an information on supportedFramework version attribute in WIX mailing list:
The version attribute complements the registry key where ‘Install’ value will be tested.
Meaning that this registry value will be checked to exist:Key: HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\<version>
Name: Install