1

had few doubt regarding customAction

<Custom Action='CustomActionId.StopService2' After='CustomActionId.StopService1>REMOVE</Custom>

so will this REMOVE flag enables this action to run my custom action only on uninstall or both Upgrade/Uninstall/Repair/Reconfigure

user3664223
  • 305
  • 3
  • 19

1 Answers1

1

Windows Services: Windows services should not be controlled or installed via custom actions, but by means of built-in MSI mechanisms: ServiceInstall, ServiceControl. These WiX elements map to the corresponding MSI tables and they support everything a normal service needs to install correctly. It is very reliable when done right. The various ways used (and abused) to install Windows Services (few are recommended).

WiX Service Example: Here is a good example of how to install a Windows service properly with MSI / WIX: https://github.com/rstropek/Samples/tree/master/WiXSamples/WindowsService

REMOVE: As to the property REMOVE. It will be set during several MSI operations: modify, remove, upgrade. During full uninstall it will be set to REMOVE=ALL, in other scenarios it is set to a feature list which will be affected during the maintenance operation. Conditions are hard. Here is an older answer on conditions.

Major Upgrade: Keep in mind that during a major upgrade operation there is both an uninstall of the old version and an install of the new version happening. REMOVE will be set in the version being uninstalled, but generally not in the version being installed.

If you want to skip the action during a major upgrade you could try: (REMOVE~="ALL") AND (NOT UPGRADINGPRODUCTCODE) as explained in this answer. Here is a longer answer on conditions and their permutations.

Condition Debugging: You can debug conditions by using VBScripts to show message boxes during installation as explained here (towards bottom). This can help a lot to take out the guesswork. Just run the setup and show message boxes for when your custom actions run - I guarantee you there will be surprises. Conditions can reach a state when such debugging is necessary. See this example.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164