I created a 3 service project (below) which uses a project installer for each service. I then added an installer project which installs the services into service manager. Here was my workflow:
- Create 3 services in a solution in Visual Studio 2008. Naming each service as Service1, Service2 and, Service3. (Being sure to change the actual service names to their respective names in the properties window.)
- Added an Installer project to this solution.
- Added the project outputs from the three service projects to the installer project.
- Added custom actions for all three services in the installer for Installing the services in service manager.
- Built and Installed.
This gives me three distinct services in service manager: Service1, Service2 and Service3
Enjoy!
http://code.google.com/p/multi-service-install/
EDIT:
I have updated the code in the repository to have one executable but two services. Each service installs to the service manager with its own name and ability to start/stop. I think this is what you're wanting, correct? Here is what I did:
- Created a service project.
- Added a second service to the same project (with a unique service name).
- Added an installer to both services (ServiceA and ServiceB).
- In the ProjectInstaller.Designer.vb file I changed the Me.Installers.AddRange line to show both of the service installers. (Me.ServiceInstaller1, Me.ServiceInstaller2)
- In the Main entry point of the main service (ServiceA in my case), I set the ServicesToRun variable to an array of ServiceBase containing all the services that I want it to run (ServiceA and ServiceB). This is an important step as the service manager sets a property based on the number of arguments here - either to allow multiple instances of the same exe or only a single instance.
- Add an installer project and use the output of Services.
- Add a custom action using the output from Services.
The code can still be downloaded from the same link as above.
Thanks!