Showing posts with label Installer. Show all posts
Showing posts with label Installer. Show all posts

08 December 2009

WiX Lessons Part 2

Today I did some localization of my WiX based installer and learned, that Windows Installer must have a very old code base. While localization with WiX is really easy it inherits some limitations that you don’t expect nowadays. First you cannot use UTF8 or Unicode to define your string tables. No, you need to specify windows codepages that should be used for a concrete language. Unicode is not supported. So you have to dig in old documentation for appropriate codepages (Luckily I can use Windows-1252 for West European Languages). Second you cannot simply build one msi for all languages. You must build a msi package for every language. Then you can either use a bootstrapper to decide which msi to start, or you can use some black magic on the command line which uses transformations at runtime to morph one msi into the appropriate language. Multi Language packages are not built into Windows Installer.

I had another strange behavior today regarding the usage of WiX library. I made a simple library with some very minimalistic installer gui which needs three images. projectThe three images are located inside an Images folder. See attached picture for the project structure. The files are referenced like this:

<Binary Id="Banner" SourceFile="Images\banner.bmp" />

First build succeeded than it always failed, saying that it could not find “Images\banner.bmp”. It seems some tool in the chain needs an absolute path because I fixed the build by adding the $(sys.CURRENTDIR) preprocessor directives:

SourceFile="$(sys.CURRENTDIR)Images\banner.bmp"

And you need to check “Bind files into the library file” on the Build page of the project properties. Else the library contains only the filenames and every project using the library must have access to the absolute path of the images. By default this is unchecked which imho corrupts the meaning of a redistributable library.

29 October 2009

WiX Lessons Learned

The last week I was playing around with the Windows Installer XML to create a simple setup for a very simple product implemented with .NET. All I needed to do was to copy some files, install a service under a custom account, let the user enter the address of some web services.
These features are hot:
  • open source
  • frontend for the built-in windows installer
  • done by people who know windows installer inside out
  • simple declaration of files and actions in xml
  • simple install/deinstall of services with properties like windows account or description
  • custom actions can done with .net very easily, they have read/write access to properties via a session object (see tutorial)
  • you can use managed custom actions for easy validation of custom dialogs
  • can easily integrated into automatic msbuild builds
  • very good logging capabilities which helps you on debugging
  • property based, declarative style
  • property values can be changed by administrators to support customized automatic install on clients
  • support for commit/rollback and repair/maintenance mode
But this is what bites me:
  • Bringing new Custom Dialogs (e.g. query user/password) into the dialog chain is really a pain in the ass. The chaining is done through adding event-actions to the next/back buttons which open new dialogs. Adding some conditional logic if a dialog should be shown or not has to be done by attaching conditions on the adding of event actions of the Next button of the previous dialog and the Back button of the following dialog. An you have to deal with this because on Repair/Maintenance Mode your need probably another dialog sequence.
  • Managed Custom Actions don’t seem to work in elevated mode. The bad thing is, that the installation succeeds without an error, and the custom action is ignored (that is unless you look into the log file).
  • There is no easy way to manipulate files, say app.config on the fly during installation. There is an XmlConfig extension you can use, but using it is rather crude, if you know how to do it in managed code.
  • The GUI support is very limited, you can have edit, password, combobox, listbox, check and radio controls, but layouting is done by entering x and y coordinates by hand. Browsing for a file is impossible, you can browse only for directories.
Other things:
  • You need the WiX tutorial or you are lost
  • You need DTF (Deployment Tools Foundation) for managed custom actions
    • it is included in the WiX package
    • the documentation is hidden in the doc folder of you installation … it is neither linked from the WiX documentation nor to be easily found on the internet

  • If you are a mortal .NET developer you have to do bend your mind to understand it, the windows installer technology sometimes feels like C64 basic with line numbers. Don’t be afraid, after one or two frustrating days you will get it.