I’ve been working on a Windows Service for one of our projects recently and came to what I’m sure others have encountered and that is creating the installer without the need for command prompt.
I’ve been using Visual Studio 2008 to develop the project and as you may or may not know you need to install a windows service in order to test it, you cannot debug and test direct from VS. Microsoft have nicely packaged InstallUtil.exe which can be used from the VS command prompt to install your service and get it up and running.
Now, InstallUtil is fine whilst you are in the early stages of development, but when you get closer to deployment there are a few things that need to be considered:
You can package most of the dependancies together with your solution (the .net framework is usually set to download rather than compile within) but you dont really want to have your end users runnng command prompts to get your service up and running, therefore you need to think about the distribution, that’s where an MSI installer comes in.
An MSI can be added to a project by using the VS project template and selecting “Setup and Deployment”. Once added there are a few things that need to be done to get you installing:
- Right click your installer and select “Project Output” – select your service and make sure it is set to primary output.
- The point which was had me hunting the internet for hours was right click and select “View Custom Actions” from the window that opens right click the root node and select “Add Custom Action” select application folder and then select your service. This will ensure that when your service is installed it is registered in the Services MMC.
And that’s it! Hopefully I havent missed anything but let me know it I have.