Using WiX to install a service
Now that you know how to install a service from the command line, let's look at how to do it with an installer. WiX has an element called ServiceInstall that you can use to add a new service to the services management console. This assumes that you've already created the executable file that will become the end point for your service, as discussed earlier.
First of all, we'll use the familiar Component
and File
elements to install the .exe
to the install
directory on the target machine. Add the following code to your WiX project:
<DirectoryRef Id="INSTALLFOLDER"> <Component Id="CMP_WindowsService1" Guid="3D3DE5C1-7154-4c61-9816-248A85F6DEBF"> <File Id="WindowsService1.exe" Name="WindowsService1.exe" KeyPath="yes" Source=".\WindowsService1.exe" /> </Component> </DirectoryRef>
Next, add a ServiceInstall
element to the same component to register the WindowsService1.exe...