Creating a Windows Service in Visual Studio 2010 Part 2

This is the second article on Creating a Windows Service in Visual Studio. The first article is located here, and covers creating the service. 

This article will cover creating the Setup and Deployment project. 

 

Add a new project to your Service project.

In Solution Explorer, right-click the Solution, point to Add, and then click New Project.

Under Project Types, click Setup and Deployment Projects or Setup and Deployment.

Under Templates, click Setup Project.

In the Name box, type ServiceSetup.

In the Location box, type C:\, and then click OK.

Tell the deployment project what the deployment project will package.

In Solution Explorer, right-click ServiceSetup, point to Add, and then click Project Output.

In the Add Project Output Group dialog box, click LogWriterService in the Project box.

Click Primary Output, and then click OK.

For correct installation, you have to add only primary output. 

Add the custom actions

In Solution Explorer, right-click ServiceSetup, point to View, and then click Custom Actions.

Right-click Custom Actions, and then click Add Custom Action.

Click Application Folder, and then click OK.

Click Primary output from the service, and then click OK. Notice that Primary output appears under Install, Commit, Rollback and Uninstall.

By default, Setup projects are not included in the build configuration. 

Build the solution

Right-click LogWriterService, and then click Build. Then, right-click ServiceSetup, and then click Build.

Install the service

Right-click ServiceSetup, and then click Install.

In the ServiceSetup dialog box, click Next three times. Notice that a progress bar appears while the Setup program is installing the service.

When the service is installed, click Close.

 


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences