Overriding Default Methods on Installation Components
By default, every installation component has the following methods:
- Install — All of the installation functions the installer must perform are carried out within this method. The ProjectInstaller class (or any class with the RunInstallerAttribute value set to true) calls Install on each of the installation components it contains, and then calls either Commit (if the installations were all successful) or Rollback (if any errors occurred).
- Commit — Commit is called after the Install method has been successfully run on all of the installation components the installer class contains. At this point, all of the installations are committed. Usually, to avoid raising exceptions, no processing is done in the Commit method.
- Rollback — The Rollback method is used to undo all previous installation work if an error occurs anywhere within the installation process. If any of the installation components contained by the installer class raises an error, all of the installations carried out so far are undone.
- Uninstall — Uninstall is used to remove installation component resources from the system. Unlike installation, uninstall is not transactional. If one uninstall process fails, the system still attempts to uninstall all of the other resources.
Each of these methods contains default processing that will carry out the required work without modification. If desired, however, you can override and modify the processing in each step. For example, for a Service installation component, you might want to modify the default processing that occurs in the Commit procedure so that the installation process starts the service after it is successfully installed. You might also modify the Uninstall procedure so that each service is stopped before it is uninstalled.
To override default methods for an installation component
- After adding an installation component to your solution, open the installer class.
- Locate the installation component you want to modify, and access it in the Code Editor.
- Override the appropriate method and add the functionality you want. For details, see Overriding Properties and Methods.
Tip Make sure to retain the original processing necessary to install, commit, rollback, or uninstall your resources when you override methods in the ProjectInstaller class. In general, you should add code to the existing functions rather than removing existing functionality.