How to: Integrate a Topshelf Based Service With vs Setup Projects
We’ve recently started to migrate all of our Windows Services from a classic ServiceBase based approach to the hosting framework Topshelf.
Previously we used the standard ServiceInstaller / ServiceProcessInstaller tandem to integrate our services with MSI deployment.
This does not work with Topshelf (since Topshelf does the service installation itself via the Registry).
However it’s pretty easy to write a custom installer for that. You can do something like this:
Took me some time to find this. During installation the Parameter Dictionary attached to the Context
contains the full target filename of the assembly being installed (key is assemblypath).
With this path you can directly launch the /install or /uninstall command for the Topshelf based exe.
HTH
P.S.: This resource pointed me in the right direction.