I had a problem with performing a custom action only when deleting my service using Wix.
<CustomAction Id='InstallService' FileKey='Service.exe' ExeCommand='install' Execute='immediate' Return='check' Impersonate='yes'>NOT Installed</CustomAction> <CustomAction Id='UninstallService' FileKey='Service.exe' ExeCommand='uninstall' Execute='immediate' Return='check' Impersonate='yes'>Installed AND NOT REINSTALL</CustomAction> <InstallExecuteSequence> <Custom Action='UninstallService' After='StopServices'/> <Custom Action='InstallService' Before='StartServices'/> </InstallExecuteSequence>
this is a component ...
<Component Id="ProductComponent"> <File Id="MyService.exe" Name="MyService.exe" Source="..\MyService\bin\Release\MyService.exe" Vital="yes" KeyPath="yes" DiskId="1"/> ... <ServiceControl Id='ServiceControl' Name='MyService' Start='install' Stop='both'/> </Component>
When I run the installer, I get an error. Looking at the event log, I find this ...
Product: MyService - Error 1721. There is a problem with this Windows Installer package. The program required to complete this installation failed to start. Contact your support staff or package provider. Action: UninstallService, location: C: \ Program Files (x86) \ MyService \ MyService.exe, command: delete
I also tried this ...
<CustomAction Id='UninstallService' FileKey='Service.exe' ExeCommand='uninstall' Execute='immediate' Return='check' Impersonate='yes'>Installed AND NOT UPGRADINGPRODUCTCODE</CustomAction>
Note. I use custom actions to install / uninstall the service because I used TopShelf.NET
source share