1

I'm having a real headache with how Topshelf behaves when a WIX is updating a Service... I have looked around but I can't find a specific answer for this particular issue.

First my Custom Actions on my Product.wxs:

<InstallExecuteSequence>
<Custom Action="UpgradeService" Before="InstallFiles">(INSTALLED)</Custom>
<Custom Action="InstallService" After="InstallFiles">(NOT REMOVE)</Custom>
<Custom Action="UninstallService" Before="RemoveFiles">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE~="ALL")</Custom>
</InstallExecuteSequence>

<CustomAction Id="InstallService" Directory="INSTALLFOLDER" Execute="commit" Impersonate="no" ExeCommand="cmd.exe /c &quot;MyService.exe install start&quot;" Return="check" />
<CustomAction Id="UninstallService" Directory="INSTALLFOLDER" Execute="deferred" Impersonate="no" ExeCommand="cmd.exe /c &quot;MyService.exe uninstall&quot;" Return="ignore" />
<CustomAction Id="UpgradeService" Directory="INSTALLFOLDER" Execute="deferred" Impersonate="no" ExeCommand="cmd.exe /c &quot;MyService.exe uninstall&quot;" Return="check" />

InstallService and UninstallService work as intended. UpgradeService is the one that should be called before installing the new files, no matter if it is a minor update or a major upgrade.

The problem is, when version 1.0.0.0 is already installed, and I install the MSI with version 1.0.1.0, Topshelf tells me that "This service has already been installed", though Windows validates the installation (Control Panel's list of installed apps shows the new version).

So two questions:

  1. Seems like the new MSI does not call the "UpgradeService" custom action, but I have no way to prove it. Is there a way to track whether the custom actions are acknowledged by the installer?
  2. I'm also aware on what to do when doing a Major Upgrade (change the UpgradeCode), as per the WiX documentation details. However, this is a minor update. Am I missing any further settings?

Thanks in advance!

EDIT:

I got suggested to use ServiceInstall and ServiceControl, but I run into the same issue... Here's how it looks on my WXS file:

<ServiceInstall Id='MyService.exe' Name="MyService" Type='ownProcess' Start='auto' Vital='yes' ErrorControl='normal' />
<ServiceControl Id='MyService.exe' Start='install' Stop='both' Remove='uninstall' Wait='yes' />

Problem with "This service has already been installed" persists :(

doydoy
  • 31
  • 3
  • Why do you need to use any custom actions? WiX/MSI built in ServiceInstall and ServiceControl should be able to easily handle installing any service no matter what language/framework/compiler was used to create it. – Christopher Painter Jul 02 '20 at 15:26
  • Same comment as Chris => use the built-in constructs. I have [this answer describing various ways to register / set up a Windows service](https://stackoverflow.com/a/61903256/129130). I only recommend the MSI built-in constructs for end user deployment. – Stein Åsmul Jul 02 '20 at 22:30
  • I just tried it for kicks, but I get the same error... Please check my edit of the OP. – doydoy Jul 03 '20 at 07:57
  • I added some WiX sample links to [the list of Windows service installation options](https://stackoverflow.com/a/61903256/129130). Maybe check again. – Stein Åsmul Jul 03 '20 at 10:44

0 Answers0