Thursday 29 March 2012

Adding JDK1.7 as a prerequisites using Wix Installer

To add JDK 1.7 as prerequistes in 32-bit system. Following things should be done in order to install the JDK if it is not present in the target machine.

1. Create a Custom Bootstrapper Manifest Generator Package using BMG tool or manually create the Product.xml and Package.xml . Refer this link  for How to Create BMG Package files.http://msdn.microsoft.com/en-us/library/ms165429.aspx. Copy the BMG package folder to the C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages location.

2. Then, in your Wix installer project Add the following configuration Part (Product.wxs)


    <Property Id="JDK32">
      <RegistrySearch Id="JDK_CURRENT_VERSION_REGSEARCH" Key="SOFTWARE\JavaSoft\Java Development Kit" Name="CurrentVersion" Root="HKLM" Type="raw" Win64="no"/>
    </Property>
    <Condition Message="[ProductName] requires Java Development Kit.">
      <![CDATA[Installed OR (JDK32 >= "1.6")]]>
    </Condition>

3. Unload the Wix Project and edit the project. Add the following config under the new ItemGroup


  <ItemGroup>
    <BootstrapperFile Include="JRE1.7.Bootstrapper.Package">
        <ProductName>JRE 1.7</ProductName>
        <Install>true</Install>
    </BootstrapperFile>
  </ItemGroup>

4.Add the following Target
 <Target Name="AfterBuild">
    <GenerateBootstrapper ApplicationFile="$(TargetFileName)" ApplicationName="InstallerName" BootstrapperItems="@(BootstrapperFile)" ComponentsLocation="Relative" CopyComponents="True" OutputPath="$(OutputPath)" Path="C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\" Culture="en" />
  </Target>

5. Build the Wix Solution . Now you can find your setup.exe under the OutPut Path.