Game Development Reference
Custom Installer Actions
Using the boilerplate setup templates is fine and dandy, but applications with any
sort of complexity often require that custom steps be performed during installa-
tion, such as the creation of databases, publishing of reports, user personalization,
product license key evaluation, and so forth. These steps can be performed
through the use of custom installation actions, which are code classes that you can
compile within your solution, and then point the installation process at them. To
start, we will add a new item to the application project, as shown in Figure 46.15.
Adding a new Project Item.
The item we are adding is an Installer Class (shown in Figure 46.16), which is a
class that is decorated for processing by the Visual Studio Installer. This class inher-
its from Installer , which exists in the System.Configuration.Install namespace.
This class provides four methods (Install, Commit, Rollback, and Uninstall),
which can be overridden to run custom functionality at the appropriate state in
the installer. The example provided with this chapter simply displays a message
box in the constructor; although in a real world implementation you would over-
ride the four methods appropriately.
The four override methods of Installer are not always called on the same instance of the class.
Therefore, it is important that each method can run independently of the other methods or class
instances in terms of data persistence and state.
Figure 46.17 shows the simple Installer class implementation provided with the
example for this chapter.