C# 如何为 Windows 服务创建安装项目以自动安装它?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19965379/
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
C# How to create a Setup project for a Windows Service to install it automagically?
提问by S.H.
I have seen multiple Windows Services getting installed in my computer with just an Setup.exe or .msi... is it something special that it needs to be done with the setup project to let such Windows Services installed in a easy way without Installutil.exe?
我已经看到多个 Windows 服务安装在我的计算机中,仅使用一个 Setup.exe 或 .msi...是否需要通过安装项目完成一些特殊的工作,以便在没有 Installutil 的情况下以简单的方式安装此类 Windows 服务。可执行程序?
I have tried and it just doesn't install the Service. I know how to use Installutil but that I would think it's just for testing. I need to be able to install my windows service with an Setup.exe because I want to distribute my Service with its configuration Tray app.
我试过了,它只是没有安装服务。我知道如何使用 Installutil 但我认为它只是为了测试。我需要能够使用 Setup.exe 安装我的 Windows 服务,因为我想通过其配置托盘应用程序分发我的服务。
What would be the correct way to install the service and then my app? They both use a same DLL created in the same solution.
安装服务然后安装我的应用程序的正确方法是什么?它们都使用在同一个解决方案中创建的同一个 DLL。
Problem while Building a Setup Project for a windows Service?
I looked at the link above but its about the Setup Project which I already know how to do, the problem is how to make my Setup project working... my DLL is getting up in place, the Tray app is working as well, the problem is the Service not getting installed it is just giving me the .exez
我查看了上面的链接,但它是关于我已经知道如何做的安装项目,问题是如何使我的安装项目工作......我的 DLL 正在就位,托盘应用程序也在工作,问题是服务没有安装它只是给了我 .exez
but I need it to be installed correctly like be up and running at reboot and in the Service Control Manager.
但我需要正确安装它,例如在重新启动时和在服务控制管理器中启动并运行。
采纳答案by mynkow
Option 1
1. Download Wix
2. Download and install Wix Windows Service Setup Project Template
3. Create a new wix setup project and see what you get
选项 1
1. 下载Wix
2. 下载并安装Wix Windows 服务安装项目模板
3. 创建一个新的 wix 安装项目,看看你得到了什么
This is the easiest way to create a *.msi without any option windows
这是在没有任何选项窗口的情况下创建 *.msi 的最简单方法
Option 2
Follow this blog post. Same as option 1 but without the project template. If you go the WiX route sooner or later you will see that the project template provides basic stuff. If you want more advanced stuff you need to learn WiX a little bit and use its candle.exe, light.exe, pyro.exe etc.
选项 2
关注此博客文章。与选项 1 相同,但没有项目模板。如果你迟早走 WiX 路线,你会看到项目模板提供了基本的东西。如果你想要更高级的东西,你需要稍微学习一下 WiX 并使用它的蜡烛.exe、light.exe、pyro.exe 等。
Option 3
I wrote a short posthow I usually do this.
选项 3
我写了一篇短文,我通常是如何做到这一点的。
Good luck
祝你好运
回答by fjsj
Here is a simple template for creating a *.msi installer for a Windows Service with WiX:
这是一个用于为带有 WiX 的 Windows 服务创建 *.msi 安装程序的简单模板:
http://www.schiffhauer.com/wix-template-for-installing-a-windows-service/
http://www.schiffhauer.com/wix-template-for-installing-a-windows-service/
I was able to specify my DLL dependencies with File
tags.
我能够用File
标签指定我的 DLL 依赖项。