Max
Max

Reputation: 9879

How install managed service from WiX?

Is it possible/recommended to use the InstallService element to install a Windows service written in managed code (C#)? (I tried it and it does install the service, but the service won't start)

Or does this require a custom action which invokes Installutil?

Or is there another way to do this?

Upvotes: 1

Views: 2739

Answers (2)

Stanislav Dvoychenko
Stanislav Dvoychenko

Reputation: 1333

I'm in a study of wix myself right now and has just succeeded to install/uninstall a managed service with just a standard ServiceInstall/ServiceControl way (and why not if we can just use sc for it). From what I read and agree with, using a custom task with installutil is considered a bad practice: I used to install perf counters in my .net installer, but now I'll just go the wix way for it.

By the way I had to add a ServiceControl element so service was started after the install (Start attribute) and more importantly for me, completely uninstalled during uninstall (Remove attribute).

  <ServiceControl Id='ControlStansWinService' Remove='both' Name='StansWinService' Start='install' Stop='both' Wait='yes' />

I've published my findings so far here, hope you can find it useful.

Upvotes: 3

Piyush
Piyush

Reputation: 53

You should use the WIX InstallService element as it does all the work of installing the service and starting and stopping/removing the service on install and uninstall. If you use custom action to invoke InstallUtil to install the servive, then you have to do the start and stop of the service again manually using CustomAction.

Upvotes: 0

Related Questions