Wednesday, January 12, 2011

Use a Compiled Setup Project to Install the Windows Service

Assuming you have configured the Windows Service project, follow these steps to add a deployment project that packages the service application so that the service application can be installed:
  1. Add a new project to your LogWriterService project. To do this, follow these steps:
    1. In Solution Explorer, right-click Solution 'LogWriterService' (1 project), point to Add, and then click New Project.
    2. Click Setup and Deployment Projects under Project Types, and then click Setup Project under Templates.
    3. In the Name text box, type ServiceSetup.
    4. Type C:\ in the Location text box, and then click OK.
  2. Tell the deployment project what to package. To do this, follow these steps:
    1. In Solution Explorer, right-click ServiceSetup, point to Add, and then click Project Output

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

    3. Click Primary Output, and then click OK.
  3. For correct installation, add only primary output. To add the custom actions, follow these steps:
    1. In Solution Explorer, right-click ServiceSetup, point to View, and then click Custom Actions

    2. Right-click Custom Actions, and then click Add Custom Action.
    3. Click Application Folder, and then click OK.
    4. Click Primary output from LogWriterService (Active), and then click OK.


      Notice that Primary output appears under Install, Commit, RollbackUninstall.
      and
  4. By default, setup projects are not included in the build configuration. To build the solution, use one of the following methods:
    • Method 1
      1. Right-click LogWriterService, and then click Build.
      2. Right-click ServiceSetup, and then click Build.
    • Method 2
      1. On the Build menu, click Configuration Manager to build the whole solution.
      2. Click to select the Build check box for ServiceSetup.
      3. Press F7 to build the whole solution. When the solution is built, you have a complete installation package that is available for the service.
  5. To install the newly built service, right-click ServiceSetup, and then click Install.
  6. In the ServiceSetup dialog box, click Next three times. Notice that a progress bar appears while the service installs.
  7. When the service is installed, click Close.


No comments:

Post a Comment