Couple of months back I created a post about using Windows Installer Project in VS 2010 and how to create MSI from that. At that time I had very simple requirement to work on, create an installation package that just installs our product … recently that requirement got changed a bit and now I am suppose to perform some post installation processes once installation is done and to make things seamless, I have to include them as part of installation process (from my experience, only thing that doesn’t change is change in requirements … which is kind of good … because as soon as requirements stop changing … you are out of job)
But before we dig deep, few things we need to get familiar with…
Custom Actions: from MSDN,
Custom actions are a Windows Installer feature that allows you to run code at the end of an installation to perform actions that cannot be handled during installation. The code can be in the form of a .dll, .exe, script, or assembly. For example, you might want to create a local database on the target computer during installation. You could create an executable file that creates and configures the database, then add that executable file as a custom action in your deployment project.
Custom Actions can be performed on 4 different stages of installation, INSTALL, COMMIT, ROLLBACK, and UNINSTALL. Each of these stages are pretty much self-explanatory. You can perform custom action at any of above mentioned stages to meet your requirements.
Main task of this section is to get value of parameters from UI (installation screens/steps) and pass those parameters (if configured) to installer class to manipulate installation process
Just as a side note: If your Install and Commit stages don’t have same project output from installer class then you might see error related to “Install State” so I think it is better to make sure that both of them has same project output or even any DLL, or EXE or anything in between .
Installer Class: from MSDN
This is the base class for all custom installers in the .NET Framework. Installers are components that help install applications on a computer.
In this class you can use different methods specific for different installation stages like Install, Commit, Rollback and Uninstall.
All you have to do is to write up a code specific to specific phases of installation process ,and that code will be executed at occurrence of that event. In second part of this post I will show how these method can be used to manipulate installation process and make it more dynamic.
That’s it for this part. In next part I will explain actual implementation process.
It’s Just A Thought …