Search This Blog

Thursday, November 4, 2010

Deploying a Windows Service with a Visual Studio "Setup and Deployment" project

Installing Windows Services using the “Setup and Deployment” template and creating a “Setup” project is significantly superior to using the “Installutil” command-line utility, but the steps involved in setting up a windows service to install using one of these projects can be a little involved.

Here is the most concise description available on-line:

http://msdn.microsoft.com/en-us/library/zt39148a.aspx#4803

Please note that the section that I always get hung up on is adding the service to the "custom actions" section of the setup and deployment project:

To add a custom action to the setup project

  1. In Solution Explorer, right-click the setup project, point to View, and then click Custom Actions.

    The Custom Actions editor appears.

  2. In the Custom Actions editor, right-click the Custom Actions node and click Add Custom Action.

    The Select Item in Project dialog box appears.

  3. Double-click the Application Folder in the list to open it, select Primary Output from MyNewService (Active), and click OK.

    The primary output is added to all four nodes of the custom actions — Install, Commit, Rollback, and Uninstall.

  4. In Solution Explorer, right-click the MyServiceSetup project and click Build.

This step is not obvious at all, which is why I consistently miss it (and why, from Googling around, it looks like many other people miss it too).