Wix custom action only on deletion

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

+4
source share
1 answer

It’s best to associate a custom action with a component’s action state.

 <InstallExecuteSequence> <Custom Action="UninstallService">$ProductComponent=2</Custom> <Custom Action="InstallService">$ProductComponent=3</Custom> </InstallExecuteSequence> 

In addition, you will need CustomAction elements for Execute='deferred' .

In addition, the text in the CustomAction element is CustomAction allowed if you are creating a custom script action. This is not like what you are doing.

Adding custom actions requires some understanding. Unfortunately, a third-party platform will force you to use custom actions .

+4
source

All Articles