Windows Service Installer in C#

This is the follow up article for the previous one. In order to install the service we need to use the installutil console command, which comes with the .NET Framework.

To create a setup project for your service, Add a new project to the existing solution of Type Setup and Deployment Projects and the template Setup Project.

In Solution Explorer, right-click the setup project, point to View, then choose Custom Actions. The Custom Actions editor appears.

In the Custom Actions editor, right-click the Custom Actions node and choose Add Custom Action. The Select Item in Project dialog box appears.



Double-click the application folder in the list box to open it, select primary output from TestService (Active), and click OK. The primary output is added to all four nodes of the custom actions Install, Commit, Rollback, and Uninstall.





Once its done Build the project. (Do the release build for the product deployment). This can be done by right click on the Build project and then Select Build

After succesful build .msi file will be generated.

Double click the .msi file for Installing.










Go to the services pane and see the installed the servies

You can uninstall the service by going to Add or Remove Programs