I am trying to build an MSI project, and during installation I am installing a Windows Service. If that service fails to be installed, I want to initiate rollback and cancel the installation.
I have already built an installer class and overridden the install and uninstall method. How can I initiate rollback?
First you should know that using InstallUtil custom actions ( regardless of how documented and written about they are ) are not a good choice. Throw them away. The same goes for the Visual Studio Deployment Project that you are using to consuem your custom action.
The best solution lies in leveraging Windows Installer built-in support for creating and starting services. Use InstallShield 2010 Limited Edition ( Free ) or Windows Installer XML ( FOSS ). These tools expose the ServiceControl table which has a Wait column that allows you to teach MSI:
ServiceControl Table