Reputation: 194
I have a WIX bootstrapper application that installs a Windows Service (MSI) and an EXE. I've been trying to check for the presence of the .NET 4.0 framework as a prerequisite for the windows service installer. I would like to stop the installer if the framework is not present and point them to where they can download it. Currently the service installer ignores the condition and tries to install the service regardless if the framework is present or not.
This snippet is in the windows service installer:
<Product Id="*" Name="TestService" Language="1033" Version="1.0.0.1" Manufacturer="xxxxxx" UpgradeCode="<xxxxxxxx">
<PropertyRef Id="NETFRAMEWORK40FULL" />
<Condition Message="You need to have the .NET 4.0 Framework installed">
<![CDATA[Installed OR NETFRAMEWORK40FULL]]>
</Condition>
</Product>
This snippet is from the Bootstrapper:
<Bundle Name="BundledInstall" Version="1.0.0.0"
UpgradeCode="xxxxxx">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
<bal:WixStandardBootstrapperApplication
LicenseFile="xxxxxxxx"
LogoFile="xxxxxxxx"
/>
</BootstrapperApplicationRef>
<Chain>
<PackageGroupRef Id="MyPackage" />
<PackageGroupRef Id="ServicePackage" />
</Chain>
</Bundle>
<Fragment>
<PackageGroup Id="ServicePackage">
<MsiPackage
SourceFile="C:\Users\Max\dev\wix\pappBootstrapper\sebService.msi" Cache="no" ForcePerMachine="yes">
</MsiPackage>
</PackageGroup>
</Fragment>
Thanks for the help.
Upvotes: 2
Views: 2726
Reputation: 10120
You can make use of the WixNetfxExtension properties as defined in this page: WIXNETFXEXTENSION
For example, to check whether 3.5 framework or 3.5 SP is installed you can make use of the below properties.
NETFRAMEWORK35 - Set to #1 if the .NET Framework 3.5 is installed (not set otherwise).
NETFRAMEWORK35_SP_LEVEL - Indicates the service pack level for the .NET Framework 3.5.
To make use of these properties in your project, follow the below steps:
Step 1. Add the WiX .NET extensions library to your project If you are using WiX in Visual Studio you can add the extensions using the Add Reference dialog:
Step 2: Add the WiX .NET extensions namespace to your project
Once the library is added to your project you need to add the .NET extensions namespace to your project so you can access the appropriate WiX elements. To do this modify the top-level element in your project by adding the following attribute:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
Step 3: Reference the required properties in your project
<PropertyRef Id="NETFRAMEWORK20"/>
Step 4: Use the pre-defined properties in a condition
To check against the service pack level of the framework use the *_SP_LEVEL properties. The following condition blocks installation if .NET Framework 3.0 SP1 is not present on the machine.
<Condition Message="This application requires .NET Framework 3.0 SP1. Please install the .NET Framework then run this installer again.">
<![CDATA[Installed OR (NETFRAMEWORK30_SP_LEVEL and NOT NETFRAMEWORK30_SP_LEVEL = "#0")]]>
</Condition>
Source: How to check .Net framework versions
Upvotes: 2