Tuesday, March 30, 2010

Create a Setup Project for a Windows Service

With a Windows Service created in VS:
  1. On the File menu, point to Add Project, and then choose New Project.
  2. In the Project Types pane, select the Setup and Deployment Projects folder.
  3. In the Templates pane, select Setup Project.

Add the Windows Service exe to the setup project:

  1. In Solution Explorer, right-click Setup, point to Add, then choose Project Output. The Add Project Output Group dialog box appears.
  2. ServiceName is selected in the Project box.
  3. From the list box, select Primary Output, and click OK.
  4. A project item for the primary output of ServiceName is added to the setup project. Now add a custom action to install the ServiceName.exe file.

Add a custom action to the setup project:

  1. In Solution Explorer, right-click the setup project, point to View, then choose Custom Actions. The Custom Actions editor appears.
  2. In the Custom Actions editor, right-click the Custom Actions node and choose Add Custom Action. The Select Item in Project dialog box appears.
  3. Double-click the application folder in the list box to open it, select primary output from ServiceName (Active), and click OK. The primary output is added to all four nodes of the custom actions: Install, Commit, Rollback, and Uninstall.
  4. Build the setup project.

No comments: