如何从 WiX 安装托管服务?

发布于 2024-10-04 02:24:53 字数 248 浏览 0 评论 0 原文

是否可以/建议使用 InstallService 元素来安装用以下语言编写的 Windows 服务托管代码(C#)? (我尝试过,它确实安装了服务,但服务无法启动)

或者这是否需要调用 Installutil 的自定义操作?

或者还有其他方法可以做到这一点吗?

Is it possible/recommended to use the InstallService element to install a Windows service written in managed code (C#)? (I tried it and it does install the service, but the service won't start)

Or does this require a custom action which invokes Installutil?

Or is there another way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

仙气飘飘 2024-10-11 02:24:53

我现在正在研究 wix,并且刚刚成功地使用标准 ServiceInstall/ServiceControl 方式安装/卸载了托管服务(如果我们可以使用 sc )。
根据我的阅读和同意,使用 installutil 的自定义任务是 被认为是不好的做法
我曾经在 .net 安装程序中安装性能计数器,但现在我只需使用 wix方法

顺便说一句,我必须添加一个 ServiceControl 元素,以便服务在安装后启动(开始属性),对我来说更重要的是,在卸载过程中完全卸载(删除属性)。

  <ServiceControl Id='ControlStansWinService' Remove='both' Name='StansWinService' Start='install' Stop='both' Wait='yes' />

到目前为止,我已在此处发布了我的发现,希望您能发现它有用。

I'm in a study of wix myself right now and has just succeeded to install/uninstall a managed service with just a standard ServiceInstall/ServiceControl way (and why not if we can just use sc for it).
From what I read and agree with, using a custom task with installutil is considered a bad practice:
I used to install perf counters in my .net installer, but now I'll just go the wix way for it.

By the way I had to add a ServiceControl element so service was started after the install (Start attribute) and more importantly for me, completely uninstalled during uninstall (Remove attribute).

  <ServiceControl Id='ControlStansWinService' Remove='both' Name='StansWinService' Start='install' Stop='both' Wait='yes' />

I've published my findings so far here, hope you can find it useful.

终止放荡 2024-10-11 02:24:53

您应该使用 WIX InstallService 元素,因为它完成安装服务以及在安装和卸载时启动和停止/删除服务的所有工作。如果您使用自定义操作调用 InstallUtil 来安装服务,则必须使用 CustomAction 再次手动启动和停止服务。

You should use the WIX InstallService element as it does all the work of installing the service and starting and stopping/removing the service on install and uninstall. If you use custom action to invoke InstallUtil to install the servive, then you have to do the start and stop of the service again manually using CustomAction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文