Search code examples
wixwindows-installerinstallutil

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?


Solution

  • 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.