Sunday, February 22, 2009

Bootstrapper adventures

I'm now at the stage of creating a setup package for the application that is going to use that magnificent 3M scanner. It has a setup and deployment project already, so I just rebuild it and try installing on the test desktop. However, during the setup process I end up with an error message.

After some research, I find out that there is some driver package that needs to be installed before my application install. If I install it manually first, the installation runs smoothly. So I have to include it in the installation somehow. How hard can that be? I have no experience with installation packages, but I get a hint that a custom action can help.

I do some research and soon enough I find out that

Custom Actions Management in Deployment

Actions can only be run at the end of an installation.

That is not what I need, the drivers absolutely have to be installed prior to the application installation. I research more and find a couple of links, which teach me how to use Orca and how to execute my Custom Actions whenever I like.

MSI Custom Action DLLCustom Action Run EXE

Great! Problem solved. I edit my place my Custom Action before the installation process starts. This time, however, I encounter a '2731' error. I'm not the first one to ever get this error, of course.

Problem when trying to install .NET framwork 2.0 during MSI install

"It is probably failing because you are trying to invoke an installer when an installer is already running. You need to install separate installers sequentially, not from within one another. You would need a bootstrapper to do that. "

Well, that's what I should have known in the very beginning. OK then, now to create a bootstrapper. (And what is the bootstrapper, by the way?)

Use the Visual Studio 2005 Bootstrapper to Kick-Start Your InstallationCreating a bootstrapper for a VS Shell application

These 2 pages give me some ideas. I locate my C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages folder, create product.xml and package.xml to be as simple as possible, and now I can choose my package from MySetupProject->Properties->Prerequisites.

The application now can be installed smoothly, but there is still one thing I am not happy about. The package consists of setup.exe, the .msi package, and a subfolder with my driver package. I do not want the subfolder, that might be confusing for the user or the subfolder may get 'lost' somewhere in the process of application distribution. I'm looking for the soluton:

Bootstrapper: How to compile the application and prerequisite in single .msi package?
IExpress Installer

And the IExpress seems to work fine for me. I create the single-file installation package, copy it to the test desktop and run ... just to be presented with another error. After examining the installation log, I realise that the IExpress did not extract my driver to the subfolder, but the installer expected to find it in the subfolder. Apparently, IExpress does not support the subfolders. I need another trick. A google search returns me to the page I have seen already and I read it again, carefully ... to the end.

Creating a bootstrapper for a VS Shell application

There it is, my solution:

Unfortunately, the MSBuild task doesn't provide the option to have the configuration resource use prerequisite installers found in the target directory, so you must manually update the appropriate resource file to remove the hard-coded path that looks for prerequisites in a sub-directory of the same name.

- Open the Setup.exe program in Visual Studio's resource editor
- Double-click the resource named, SETUPCFG in the 41 folder
- Search for the "Vs Shell\" string and delete the two occurrences that appear
- Save the resource file and the Setup.exe executable will be updated automatically
- Run iexpress
- Create a new package by following the IExpress wizard's steps and make sure to include the following files ...

Some careful setup.exe editing follows (first attempt was unsuccessful, I spoiled the .exe and had to rebuild my project again) and I have the complete solution - my single-file installation package, that has a prerequisite that is installed before the installation of the main application.

However, that was not the end ...

by . Also posted on my website

No comments: