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

27 comments:

ogil0018 said...

How do I hide the checkbox or radio buttons if I don't want to use them?

Neil Sleightholm said...

Just edit the relavent theme files in the Test\Resource folder - they are just examples and aren't embedded in to the BA.

ogil0018 said...

That's what I thought, just wanted to make sure I was not missing something.

Have you tried adding a treeview onto the options page?

Do you also have any info on how to install or not install a certain feature in the msi through the ba?

Neil Sleightholm said...

No I haven't looked at a treeview or MSI features.

rowbot said...

Hi,

Any idea how I can include a license.htm for the HyperlinkTheme with the stdBa or would I need your extstdBA?

Thanks,

Neil Sleightholm said...

See my previous blog "Burn tips & ticks" http://neilsleightholm.blogspot.co.uk/2012/05/wix-burn-tipstricks.html

GY said...

Hi,

I tried your code. I disabled the Options page and turned it into a page for showing the license (the first page is a welcome page only). It works great. However, I encountered a problem. The first package's text for WIXSTDBA_CONTROL_OVERALL_PROGRESS_PACKAGE_TEXT is not cleared when the second package's text is shown. So they overlap. I tried to clear the text in OnCachePackageComplete. It didn't work.
Please help!

Thanks!

Neil Sleightholm said...

I am not sure I really follow. Is this text on your new page?

GY said...

The Text on the Setup Progress page:
Below the progress bar, where the currently installing package name is displayed. When first package is finished, it changes to the next package name.

IN method OnCachePackageBegin, I tried this, it doesn't work either:

ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_OVERALL_PROGRESS_PACKAGE_TEXT, wz);
HWND hWnd = ::GetDlgItem(m_pTheme->hwndParent, WIXSTDBA_CONTROL_OVERALL_PROGRESS_PACKAGE_TEXT);
RECT rcParent = { };
::GetWindowRect(hWnd, &rcParent);
::ScreenToClient(hWnd, (LPPOINT)&rcParent);
::InvalidateRect(hWnd,&rcParent, TRUE);
::UpdateWindow(hWnd);

Neil Sleightholm said...

Does this happen with the standard BA? I am not sure what you mean by you disable the option and turned it in to a licence page - have you inserted a new page some how?

GY said...

In the "Install" page, there are three buttons, I removed the leftmost one ("Options"), and change the second to invoke the "Options" page.

Button Name="OptionsButton" X="-91" Y="-11" Width="75" Height="23" TabStop="yes" FontId="0">#(loc.InstallNextButton)

Then add the install button to the "Options" page:

Button Name="InstallButton" X="-91" Y="-11" Width="75" Height="23" TabStop="yes" FontId="0">#(loc.InstallInstallButton)

Button Name="WelcomeCancelButton" X="-11" Y="-11" Width="75" Height="23" TabStop="yes" FontId="0">#(loc.InstallCloseButton)

I didn't try the standard BA since I want to have the banner image for the second page.

Neil Sleightholm said...

That isn't something I have really tried, I don't think you can just replace the ok button with install as install is coded to expect to be on the install page. You probably need to get it to move the correct page first but I have no idea how.

GY said...

Even without change the "Options" page, I am still seeing overlapping messages in "Setup Progress" page.
Please help!

GY said...

And I don't have the problem with standard BA.

Neil Sleightholm said...

Have you tried the version on Codeplex? I don't think it will be different but is the latest version.

GY said...

I solved the problem by adding the following code to force an update after setting the text:

RECT rcParent = { };
::GetWindowRect(m_hWnd, &rcParent);
::ScreenToClient(m_hWnd, (LPPOINT)&rcParent);
::ScreenToClient(m_hWnd, ((LPPOINT)&rcParent) + 1);
::InvalidateRect(m_hWnd,&rcParent, TRUE);
::UpdateWindow(m_hWnd);

Neil Sleightholm said...

I have to say I am still a bit confused because this code is virtually the same code as the standard BA so I don't understand why this is required.

GY said...

I don't know why, but now it works well for me. Thanks for your time.
Also found a bug of wix 3.6. It causes an AppCrash, an divide-by-zero exception if the first package is a symblink to an MSI package. The qwSuccessfulCachedProgress is zero, it causes a devide-by-zero exception when it is used to calculate the progress. A workaround is to use the actual package instead of a symblink.

Please check if you can reproduce when you have time.
Thanks!

Neil Sleightholm said...

Are you able to put an image of the repaint problem somewhere?

GY said...

Ok, there is the image: http://imgur.com/9UeM1

Another problem I just found:
There is an extra ')' for the [WixBundleName]. See image:

http://imgur.com/F9r1R

Do you know how to fix it?
Thanks!

Neil Sleightholm said...

Ok I'll take a look.

Not sure where that bracket is coming from I suspect it something in your bundle definition. The logs might help.

GY said...

You are right. The extra ')' is in my definition file.

As you see in the picture, I set the background with windows' default background color in CreateMainWindow() and ignore the color definition from the theme file.

wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);

This works fine for most of the dialogs, except the 'Setup Failed' (see image below).

http://i.imgur.com/HDLSp.jpg

I could not find the right place to force its color with windows' default color. I tried to set the windows' default to m_pTheme->rgFonts->crBackground, but it didn't work:
COLORREF boja(GetSysColor(COLOR_BTNFACE));
m_pTheme->rgFonts->crBackground = boja;

Any idea?
Thanks!

Andy said...

Hi Neil,

It's looking great btw :)

If I understand correctly, is the only way to associate (for example) 3 checkboxes on the main page with 3 msi's defined in the chain events... via a custom BA created from scratch, or can this actually be done via your extensions?

Hopefully I've got the wrong idea, as otherwise I doub't you'd have gone into so much trouble with the checkboxes on the main page...


On a lesser note, using the Bundle4 example, Light threw up an error on rebuilding (through vs2010)
The WixLocalization element contains an unexpected attribute 'Language'.

Even though "Language" is shown in intelesence, removing the attribute allowed compile to proceed. I don't need to deal with localization, but thought you may want to know.

Thanks..

Neil Sleightholm said...

You should be able to use my BA to do what you want with checkboxes.

GY said...

Hi, Neil

When I compile my bundle with my custom BA, the candle.exe could not find the WixBalExtensionExt unless I copy WixBalExtensionExt.dll to wix_3.6.3303.0 diretory. How can I tell candle to find my WixBalExtensionExt.dll in other location?

Thanks!

Neil Sleightholm said...

If you are using Visual Studio just add a reference to it and it will be found. If you are using Candle directly you can put a fully qualified path to the DLL on the command line.

Neil Sleightholm said...

Comments closed; please use discussions on CodePlex http://wixextba.codeplex.com/.