When I created a windows service using .Net I also created an installer project using VS.net 2002's built in setup project. This worked fine if all I wanted to do was copy my service.exe and service.config file to the target machine but the user would still have to run the InstallUtil utility provided by Microsoft to install the service itself. After searching on the web I didn't find anything about how to accomplish this so I thought I'd share how I did it:
In my setup project I added the InstallUtil.exe to my target files under Application Folder along with it's .config file. Under custom actions I created a custom action for Install. I call InstallUtil.exe and set the Arguments property to "[TARGETDIR]\service.exe". Then I set the InstallerClass property to False. I do the same thing for the Unistall but I set the Arguments property to /u "[TARGETDIR]\services.exe".
* warning *
Now that all being said it will work fine if the service is not already installed. If it is the InstallUtil.exe will throw an error and the install will fail. Easy to work around but only the developer will know why and how to fix it.
Everyone - Please let me know if you come up with a better or easier way to accomplish this.