作为安装过程的一部分,如何让 WiX 调用 .NET 程序集中的方法?
我正在迁移一些现有产品以使用 WiX 3.5(我正在使用 Votive VS 集成)。我正在安装的一些项目需要向第三方框架注册。要求是我必须在第三方 .NET 程序集中调用 Register() 方法来通知它我正在安装的项目是否存在。它需要一个 COM ProgID。
我不知道如何让 WiX 做到这一点。我考虑过创建一个二进制自定义操作,但我找不到将参数(包含 ProgID 的字符串)传递到该自定义操作的方法。我不想对其进行硬编码,因为我需要它成为可重用的代码。我看不到以声明方式执行此操作的方法,因为 Register() 函数是一个“黑匣子”。
伙计,这是一个陡峭的学习曲线。我在这里最好的方法是什么?
I'm migrating some existing products to use WiX 3.5 (I'm using the Votive VS integration). Some of the items I'm installing need to be registered with a third-party framework. The requirement is that I must call a Register() method in a third party .NET assembly to inform it of the presence of the items I'm installing. It expects a COM ProgID.
I can't figure out how to get WiX to do this. I thought about creating a binary Custom Action, but I can't find a way of passing a parameter (a string containing the ProgID) into that custom action. I don't want to hard-code it because I need this to be re-usable code. I can't see a way to do this declaratively because the Register() function is a 'black box'.
Man this is a steep learning curve. What's my best approach here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 WIX 的部署工具基础 (DTF)。 WIX 安装中有一个 DTF.chm 文件,其中包含大量信息。
假设您的安装过程类似于
您将需要两个自定义操作(忽略回滚和卸载)
SetupRegistration应该是立即自定义操作从 UI 触发或在设置阶段后期触发。它获取 ProgID 和所需的任何其他数据,使用 CustomActionData 对象并将其分配给名为“DoRegistration”的属性(重要,属性名称必须与第二个自定义操作相同)
DoRegistration 是延迟的自定义操作,需要在 InstallExecuteSequence 中安排,可能在 InstallFiles 之后,但这取决于情况。它提取 Session.CustomActionData 属性并获取 ProgID,然后调用您需要的任何注册方法。
Look at the Deployment Tools Foundation (DTF) for WIX. There is a DTF.chm file with the WIX installation with lots of information.
Assuming you installation process is something like
You'll need two Custom actions (ignoring rollback and uninstallation)
SetupRegistration should be an immediate custom action fired either from the UI or late in the setup phase. It grabs the ProgID and any other data needed, uses a CustomActionData object and assigns that to a property named "DoRegistration" (Important, the property name must be the same as the second custom action)
The DoRegistration is a deferred custom action and needs to be scheduled in the InstallExecuteSequence probably after InstallFiles, but that depends. It pulls the Session.CustomActionData property and gets the ProgID out, then calls whatever registration method you need.
我正在使用你所描述的一种。
我习惯在需要时调用 CustomAction(events)。就像单击按钮一样,您可以调用一个为您工作的方法。
调用自定义操作,例如:
或根据特定按钮点击调用自定义操作:
Am using a sort of what you have described.
I use to call CustomAction(events) when required. Like on clicking button you can call a method which will do work for you.
Calling custom action like:
<Custom Action="ActionName" After="InstallFinalize">CONDITION = "1"</Custom>
Or calling custom action based on specific button click: