WiX服务安装程序和自定义安装事件 [英] WiX service installer and custom install events

查看:107
本文介绍了WiX服务安装程序和自定义安装事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的(基于C#的)Windows服务,该服务是从安装程序类,我目前使用的是提供的MS,命令行

I have an existing (C# based) windows service that is derived from the Installer class and I currently use the MS supplied, command line InstallUtil to install it and uninstall it. This works fine and as part of my system I have attached event handlers to the AfterUninstallEventHandler and CommittedEventHandler events. In my case I simply use them to log messages to a custom event log - showing the install and uninstall dates and times and program versions.

此刻,我正在尝试 Wix v3.5 Beta 1 来打包一堆我的包括该服务的内容,我正在使用Wix ServiceInstall和ServiceControl替换我用InstallUtil手动执行的操作.

At the moment I am experimenting with Wix v3.5 Beta 1 to package up a bunch of my stuff including this service and I am using the Wix ServiceInstall and ServiceControl to replace what I manually did with InstallUtil.

但是,似乎Wix使用与InstallUtil完全不同的机制来安装服务.从Wix控制的服务的名称和描述中可以看出这一点(与服务程序中嵌入的内容相反),并且我的事件不再触发(如果使用了不同的安装机制,我会怀疑它们是否会触发该事件) ).

However it seems that Wix uses a totally different mechanism to InstallUtil for installing services. This is seen in the name and description of the service being controlled by Wix (as opposed to what was embedded in the service program) and that my events no longer fire (which, if a different install mechanism is being used I doubt that they would).

那么Wix是否有可能以与InstallUtil相同的方式执行服务安装,还是我只想忍受这些差异?

So is it possible for Wix to perform a service installation in the same manner as InstallUtil or am I just going to put up with the differences?

修改

Christopher建议从我的代码中剔除与服务相关的定义,并将其移至Wix安装程序项目中.这让我感到不安,因为现在我要么必须找到一种在两个单独的系统之间共享信息的方式(我不知道如何在代码和Wix项目之间共享),要么忍受在两个单独的位置定义信息(非常糟糕)软件实践).

Christopher has suggested factoring out the service related definitions from my code and moving them into the Wix installer project. This makes me uneasy as now I either have to find a way to share information between two separate systems (which I have no idea how to share between the code and Wix projects) or put up with defining the information in two separate locations (very bad software practice).

推荐答案

从Windows安装程序的角度来看,InstallUtil是一种有害的反模式,因为它会将脆弱的过程代码注入声明式编程模型中. Windows Installer长期以来都有ServiceInstall和ServiceControl表,这确实工作得很好.同样适用于Regasm和Regserver.我们更喜欢提取COM数据并将其编写到安装程序中,并让MSI负责应用注册表值,而不是加载程序集并调用入口点,以希望它能起作用.当它失败时,您不知道为什么,也无法回滚计算机的状态.

From a windows installer perspective, InstallUtil is an evil antipattern because it injects fragile out of process code into a declarative programming model. The Windows Installer has long had the ServiceInstall and ServiceControl tables and this works really well. The same applies to Regasm and Regserver. We prefer to extract the COM data and author it into the installer and have MSI take care of applying the registry value rather then loading assemblies and calling entry points in the hope that it works. When it fails, you have no idea why and you can't roll the state of the machine back.

您在活动中做什么工作?我要么消除它们,要么将它们重构为MSI可以为您做的事情.如果还不够,请编写DTF自定义操作并将其安排在InstallServices和StartServices之间.

What kind of stuff are you doing in your events? I would either eliminate and/or refactor each of them into something MSI can do for you. If it's still not enough, write a DTF custom action and schedule it between InstallServices and StartServices.

这篇关于WiX服务安装程序和自定义安装事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆