53

Is it possible to deploy a Windows Service using ClickOnce? If so, how do you achieve this?

Currently we have to use a Deployment project, and the installation process could be simplified greatly by using ClickOnce.

NoizWaves
  • 2,650
  • 6
  • 28
  • 32

3 Answers3

31

AFAIK you can't really use ClickOnce end-to-end to deploy a service; there are issues with both the file locations (ClickOnce installs into a user's profile) and installation (ClickOnce is largely side-effect free).

You can, however, write a service as an exe that can self-install/uninstall from the services list, like so; basically, you write it as as a console exe and handle some command line args, using AssemblyInstaller to [un]install from the current assembly. Another advantage is that the same approach can be used to help debugging, since you can run it from the command line.

Community
  • 1
  • 1
Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • 7
    You might want to check out the Topshelf project as a wrapper that gives you easy access to extensible features like self install / uninstall. http://topshelf-project.com/ – Norman H Oct 18 '13 at 18:04
8

I guess NO according to Choosing Between ClickOnce and Windows Installer

OrElse
  • 9,709
  • 39
  • 140
  • 253
1

Instead of ClickOnce, I like to use the approach using Inno Setup, like in here https://stackoverflow.com/a/1450051/396200

You have more control over what and how will be copied and executed.

As Marc Gravell said in his answer, I create a exe that self install my service, and then use Inno Setup to pack and deploy it. After Inno setup installed, it automatically run the exe and then my exe install my service.

Community
  • 1
  • 1