Thursday, September 10, 2009

How to create a setup project to install windows services

This post assumes that you have knowledge on windows services and how to create a windows service using visual studio. People who don't know how to create windows service please learn here.

Please follow below steps to create a setup project
1. Create a visual studio solution with a project of type Windows Service as explained in

2. Add a new project of type "Setup Project" to the solution as shown below

2. Once you click on OK button in the above step, you will see the screen below. There you notice a new project named "Setup1" is added.

3. Now right click on Setup1 project in the solution and click "Add Project Output" as shown below.

4. In "Add Project Output Group" dialog box shown below, select the windows service project in the drop down and click OK.

5. The above 4 steps are only to copy all the assemblies to specifies installation folder. Setup will not install the services in the system. To tell the setup to install services we must add custom actions. To open the custom actions window right click "Setup1" project in solution explorer and click View->Custom Actions as shown below.

6. You will see the Custom Actions tab opened like this.

7. Right click on "Custom Actions" and click "Add Custom Action".

8. That will open a dialog box which lets you choose the items from "Application Folder". Select "Primary Output From WindowsService1" in "ApplicationFolder" and click OK.

9. The above step will add this custom action to all sub folders "Install", "Commit", "Rollback", "Uninstall". Finally you will see the screen like this.

10. Build the "Setup1" project. Now you are ready to use this setup project to install/uninstall windows services. Take the setup build from WindowsService1\Setup1\Debug and use it to install/uninstall when needed.
kick it on
Shout it


zvolkov said...

If you have multiple services in your solution creating separate installers for them is not practical. I'd much rather prefer to use WiX for that, it's not that hard.

Kiran said...

Thanks a lot This information helped me a lot.

Kiran said...

It helped me too a lot.
Keep up the good work;-)

Kiran said...

Thank you so much.

Kiran said...

Thank you, I was trying to work out how to install my service from the setup for weeks and then I found this.

Good job!!!

Kiran said...

Good work dude.Keep it up..

Kiran said...

Thanks a lot for the help...
These are very helpful.. tips..
Can we put 3 - 4 service setups together in 1 single setup.

Kiran said...

thanks a lot. it takes several hours since I find this right article.

Kiquenet said...

Any final sample windows service and installer (setup.exe, wix, etc) with full source code using VS 2012 ? Now, june 2014, any updates ?

The install shield limited edition that cannot install services.
The WIX Toolset, which, while powerful is exceeding user-unfriendly and has a steep learning curve. There is even a downloadable template for installing windows services.