开发者

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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜