Showing posts with label Burn. Show all posts
Showing posts with label Burn. Show all posts

Wednesday, 3 October 2012

WiX Bootstrapper Application

EDIT: This code has been updated and is now available here http://wixextba.codeplex.com/.
I have been working with the new WiX bootstrapper applications and have created my own version based heavily on the standard BA.
This version has the following enhancements over the standard code:
  • Resized HyperlinkLicense and RtfLicense so they look the same as the default WiX UI – this is useful if you need to show an MSI internal UI.
  • Add welcome message to HyperlinkLicense install page.
  • Add support for Radio buttons on the option and install pages.
  • Add support for checkboxes on the install page (they are already supported on the options page).
  • Add support for second directory folder on the option page.
  • Add example HyperlinkTheme that supports a larger logo on the install page (see images below).
  • Add example textbox on the options page.
  • Added install version number to HyperlinkLicense install page.
  • Reformat the RtfLicense to have flat licence textbox.

Download

The source for this can be downloaded here. To use it add a reference to WixBalExtensionExt.dll (in the build folder) and add the following code to you bundle:
<BootstrapperApplicationRef Id="WixExtendedBootstrapperApplication.HyperlinkLicense" />
The code should build on any machine with Visual Studio 2010 and WiX 3.6 installed. The extended BA has been renamed to use Ext or Extended in place of Std or Standard but I have kept the filenames the same so it is easier to merge changes from the WiX standard BA.

Examples

See folder “Test” in the download for examples of using this BA.
image
image
image

Tuesday, 1 May 2012

Burn UI Customisations

I have written a couple of WiX burn UI customisations and thought they were worth sharing. They are both based on the standard WiX burn templates and can be easily implemented as mentioned in my previous post http://neilsleightholm.blogspot.co.uk/2012/05/wix-burn-tipstricks.html.

HyperlinkLicense

I changed this to include the following features:
  1. Resized to match standard WiX UIs.
  2. Add welcome text
  3. Display version number.
image

The relevant bits of code to do this is shown below, all other code it the same as the standard UI:

<Theme xmlns="http://wixtoolset.org/schemas/thmutil/2010">
    <Window Width="500" Height="390" HexStyle="100a0000" FontId="0">#(loc.Caption)</Window>


    <Page Name="Install">
        <Text X="11" Y="80" Width="-11" Height="30" FontId="2">#(loc.InstallHeader)</Text>
        <Text X="11" Y="121" Width="-11" Height="-129" FontId="3">#(loc.InstallMessage)</Text>
        <Hypertext Name="EulaHyperlink" X="11" Y="-107" Width="-11" Height="17" TabStop="yes" FontId="3" HideWhenDisabled="yes">#(loc.InstallLicenseLinkText)</Hypertext>
        <Text X="11" Y="-73" Width="246" Height="17" FontId="3">#(loc.InstallVersion)</Text>
        <Checkbox Name="EulaAcceptCheckbox" X="-11" Y="-41" Width="246" Height="17" TabStop="yes" FontId="3" HideWhenDisabled="yes">#(loc.InstallAcceptCheckbox)</Checkbox>
        <Button Name="OptionsButton" X="-171" Y="-11" Width="75" Height="23" TabStop="yes" FontId="0" HideWhenDisabled="yes">#(loc.InstallOptionsButton)</Button>
        <Button Name="InstallButton" X="-91" Y="-11" Width="75" Height="23" TabStop="yes" FontId="0">#(loc.InstallInstallButton)</Button>
        <Button Name="WelcomeCancelButton" X="-11" Y="-11" Width="75" Height="23" TabStop="yes" FontId="0">#(loc.InstallCloseButton)</Button>
    </Page>

This also requires the addition of a few items in the HyperlinkTheme.wxl file:

  <String Id="InstallHeader">Welcome</String>
  <String Id="InstallMessage">Setup will install [WixBundleName] on your computer. Click install to continue, options to set the install directory or Close to exit.</String>
  <String Id="InstallVersion">Version [WixBundleVersion]</String>

RtfLicense

I changed this to include the following features:
  1. Resized to match standard WiX UIs.
  2. Change odd looking 3D outline to a single line.
image

The relevant bits of code to do this is shown below, all other code it the same as the standard UI:

    <Page Name="Install">
        <Text X="11" Y="80" Width="-11" Height="-70" TabStop="no" FontId="2" HexStyle="0x800000" />
        <Richedit Name="EulaRichedit" X="12" Y="81" Width="-12" Height="-71" TabStop="yes" FontId="0" />
        <Checkbox Name="EulaAcceptCheckbox" X="-11" Y="-41" Width="246" Height="17" TabStop="yes" FontId="3" HideWhenDisabled="yes">#(loc.InstallAcceptCheckbox)</Checkbox>
        <Button Name="OptionsButton" X="-171" Y="-11" Width="75" Height="23" TabStop="yes" FontId="0" HideWhenDisabled="yes">#(loc.InstallOptionsButton)</Button>
        <Button Name="InstallButton" X="-91" Y="-11" Width="75" Height="23" TabStop="yes" FontId="0">#(loc.InstallInstallButton)</Button>
        <Button Name="WelcomeCancelButton" X="-11" Y="-11" Width="75" Height="23" TabStop="yes" FontId="0">#(loc.InstallCloseButton)</Button>
    </Page>

WiX Burn – tips/tricks

This post outlines some of the things I have found out since working with the new Burn code, unless otherwise stated this refers to version 3.6.2830.0 or later. For my requirements I have only needed to create single file installation setups, so none of these examples will include download code. I keep the source to resources in a folder called “Resource” so in the examples below "Resource\" is a reference to this folder.

In many cases this information has been gleaned from the WiX Users mail list. If you spot any errors or can suggest improvements please let me know.

Basic Template

This is my outline framework that I have been using to create a burn project:
<?xml version="1.0" encoding="utf-8"?>

<?ifndef Version?>
<?define Version = "1.0.0.0" ?>
<?endif ?>

<Wix RequiredVersion="3.6.2830.0" xmlns="http://schemas.microsoft.com/wix/2006/wi
"
     xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
  <Bundle Name="My Application" Version="$(var.Version)" Manufacturer="ACME" UpgradeCode="PUT-GUID-HERE
"
    HelpUrl="http://www.nowhere.com
"
    Copyright="Copyright© 2012, ACME" IconSourceFile="Resource\Setup.ico
"
    SplashScreenSourceFile="Resource\SplashScreen.bmp
"
    AboutUrl="http://www.nowhere.com
"
    Condition="((VersionNT >= v5.1) AND (ServicePackLevel >= 3)) OR ((VersionNT >= v5.2) AND (ServicePackLevel >= 2)) OR (VersionNT >= v6.0)">

    <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkLicense" />
    <WixVariable Id="WixStdbaLicenseUrl" Value="" />
    <WixVariable Id="WixStdbaLogo" Value="Resource\logoSmall.png" />
    <Variable Name="InstallFolder" Type="string" Value="[ProgramFilesFolder]ACME\My App" />

    <Chain>
      <PackageGroupRef Id="Netfx4Full" />

      <RollbackBoundary />
     
      <MsiPackage
        Id="Setup
"
        Compressed="yes
"
        SourceFile="$(var.Setup.TargetPath)
"
        Vital="yes">
        <MsiProperty Name="INSTALLLOCATION" Value="[InstallFolder]" />
      </MsiPackage>
    </Chain>
  </Bundle>
</Wix
>

Notes:

  • This template reference the .Net 4 framework, for this I just copied the WiX source but set ExePackage/@Compresses=”yes” to embed the framework in my installation.
  • The Bundle/@Condition sets the install to only run on Windows XP SP3, Windows 2003 SP2 or later.
  • The WixStdbaLicenseUrl is set to an empty string to hide the license URL hyperlink as it is not require for my installation.
  • By referencing my WiX MSI setup project in the burn project I can reference the MSI using the syntax SourceFile="$(var.Setup.TargetPath)" where Setup is the name of my project.
  • The preprocessor variable for the version allows me to set the version from my build environment.

No License UI

To create an installation without a license URL link use the following:
       <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkLicense" /> 
    <WixVariable Id="WixStdbaLicenseUrl" Value="" />

Hyperlink to local License file

If you want to have a link to local license file as part of your installation save the license file as an html document and then reference it as follows:
    <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkLicense">
      <Payload SourceFile="Resource\License.htm" />
    </BootstrapperApplicationRef>
    <WixVariable Id="WixStdbaLicenseUrl" Value="License.htm" />

This embeds the file license.htm file within the bundle and extracts it when the installation is run, if the user clicks the hyperlink then the file is loaded in the default browser.

RichText box license dialog

To create an installation with the license displayed in a richtext control use the following:
    <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
    <WixVariable Id="WixStdbaLicenseRtf" Value="Resource\License.rtf" />

Custom UI

If you want to customise the standard UIs copy them from the WiX source and reference them like this:
    <WixVariable Id="WixStdbaThemeXml" Value="Resource\HyperlinkTheme.xml" />
    <WixVariable Id="WixStdbaThemeWxl" Value="Resource\HyperlinkTheme.wxl" />

.Net Framework 3.5 SP1 Install

To install the .Net Framework v3.5 SP1 I use this:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Fragment>
    <util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v3.5" Value="Version" Variable="Netfx35Version" />

    <PackageGroup Id="Netfx35">
      <ExePackage Id="Netfx35
"
        Cache="no
"
        Compressed="yes
"
        PerMachine="yes
"
        Permanent="yes
"
        Vital="yes
"
        Name="Redist\dotnetfx35.exe
"
        SourceFile="..\Redist\dotnetfx35.exe
"
        InstallCommand="/q /norestart /lang:ENU
"
        RepairCommand="/q /norestart /lang:ENU
"
        UninstallCommand="/q /norestart /lang:ENU
"
        InstallCondition="NOT Netfx35Version OR (Netfx35Version &lt; v3.5.30729.1)" 
        DetectCondition="Netfx35Version AND (Netfx35Version &gt;= v3.5.30729.1)">
        <ExitCode Value ="3010" Behavior="forceReboot" />
      </ExePackage>
    </PackageGroup>
  </Fragment>
</Wix
>

Signing a package

This is the approach I use (http://wix.sourceforge.net/manual-wix3/insignia.htm):

  1. insignia -ib Setup.exe -o engine.exe
  2. signtool engine.exe (extra parameters excluded for simplicity)
  3. insignia -ab engine.exe Setup.exe -o Setup.exe
  4. signtool Setup.exe

You can also use modify the wixproj to override the SignBundleEngine and SignBundle targets (sample copied from this thread http://sourceforge.net/mailarchive/message.php?msg_id=29179087):

<Target Name="SignBundleEngine">
  <Exec Command="&quot;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\signtool.exe&quot; sign /f privatekey.pfx /p mypassword /t http://timestamp.comodoca.com/authenticode &quot;@(SignBundleEngine)&quot;" />
</Target>
<Target Name="SignBundle" >
  <Exec Command="&quot;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\signtool.exe&quot; sign /f privatekey.pfx /p mypassword /t http://timestamp.comodoca.com/authenticode &quot;@(SignBundle)&quot;" />
</Target>

I found this problematic because:

  1. My certificate is not in the certificate store so I have to use signtool (as above).
  2. Signtool is not in the path or referenced via an environment variable so you have to know the path to the location of the Platform SDK you have installed and hard code it.
  3. You signing password is hard coded in the wixproj file.

Edit 07/05/2012: ARPSYSTEMCOMPONENT not required as this supplied by burn.