visual-studio 从 Visual Studio 安装程序项目安装 Windows 服务
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/407109/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing a windows service from a Visual Studio Installer project
提问by Ben
A colleague has written a Windows Application and left me to do the installers. I have created the installer project through Visual Studio and added the primary output of the service project to the new project.
一位同事编写了一个 Windows 应用程序,让我来做安装程序。我已经通过 Visual Studio 创建了安装程序项目,并将服务项目的主要输出添加到新项目中。
When I run the installer it creates the correct folders and copies the dlls, exe and config file in, but it doesn't do the actual install of the service.
当我运行安装程序时,它会创建正确的文件夹并将 dll、exe 和配置文件复制到其中,但它不会执行服务的实际安装。
The service isn't listed in the Services window, and if I double click on the exe I'm told I need to run installutil to install the service.
该服务未在“服务”窗口中列出,如果我双击该 exe,我会被告知我需要运行 installutil 来安装该服务。
How do I make the installer do this bit for me? I found this article:
我如何让安装程序为我做这件事?我找到了这篇文章:
http://www.codeproject.com/KB/install/InstallService.aspx
http://www.codeproject.com/KB/install/InstallService.aspx
but that seems overly complex for what I would expect to be pretty basic.
但这对于我期望的非常基本的内容来说似乎过于复杂。
采纳答案by thaBadDawg
I used this article:
我使用了这篇文章:
How to create a Setup project for a Windows Service in Visual Basic .NET or in Visual Basic 2005
如何在 Visual Basic .NET 或 Visual Basic 2005 中为 Windows 服务创建安装项目
Felt pretty dumb that I couldn't figure it all out until I went through all of the steps in this article. It's not a trivial exercise by any means.
在我完成本文中的所有步骤之前,我无法弄清楚这一切,我感到非常愚蠢。无论如何,这都不是一项微不足道的练习。
回答by dmck
For those who are looking for updated instructions for Visual Studio 2010 (instructions in answer are for VS 2005) check the following link:
对于那些正在寻找 Visual Studio 2010 更新说明(回答说明适用于 VS 2005)的人,请查看以下链接:
Walkthrough: Creating a Windows Service Application in the Component Designer(note that "other versions" [VS 2005, VS2008] are available from the same link)
演练:在组件设计器中创建 Windows 服务应用程序(请注意,“其他版本”[VS 2005、VS2008] 可从同一链接获得)
回答by John
I had this issue in my case the problem was I neglected to add the custom actions for the installer project. To find these right click project->"view"->"custom actions" under there it needs the primary output added to the folders.
在我的情况下,我遇到了这个问题,问题是我忽略了为安装程序项目添加自定义操作。要在那里找到这些右键单击项目->“视图”->“自定义操作”,它需要将主要输出添加到文件夹中。

