I am having a problem getting a Custom action to only run when I am uninstalling 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 the 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 in the event log I find this ...
Product: MyService -- Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: UninstallService, location: C:\Program Files (x86)\MyService\MyService.exe, command: uninstall
I have also tried this ...
<CustomAction Id='UninstallService'
FileKey='Service.exe'
ExeCommand='uninstall'
Execute='immediate'
Return='check'
Impersonate='yes'>Installed AND NOT UPGRADINGPRODUCTCODE</CustomAction>
Note: I am using custom actions to install/uninstall the service because I've made use of TopShelf.NET