WiX 中的自定义操作方法调用

发布于 2024-10-29 17:16:13 字数 171 浏览 3 评论 0原文

假设我已经编写了一个自定义操作托管类库,我计划在 WiX 安装项目中使用它。类库包含几个具有“安装”方法的类。我计划从我的安装包中将这些方法作为自定义操作启动,因此我使用 CustomActionAttribute 标记所有这些方法。那会发生什么?是只启动一种方法,还是全部启动,或者安装项目编译失败?这被认为是一个好的做法吗?

Lets imagine I've written a custom actions managed class library that I am planning to use in WiX setup project. The class library contains few classes which have "Install" methods. I am planning to launch those methods from my setup package as a custom action, so I mark all of them with the CustomActionAttribute. What will happen then? Will only one method be launched, or all of them, or the compilation of the setup project will fail? Is this considered a good practice at all?

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

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

发布评论

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

评论(3

空心空情空意 2024-11-05 17:16:17

您永远不应该真正使用自定义操作来安装东西,因为这就是整个 MSI 的目的。

如果您确实想这样做,请确保在 ExecuteInstallSequence 表中安排您的操作,否则它们将不会运行。此外,请确保您的 dll 包含在二进制表中,并且您的自定义操作引用该二进制文件。

You should never really be installing things with custom actions, since that's what the whole MSI thing is for.

If you do want to do this though, make sure you schedule your actions in the ExecuteInstallSequence table, otherwise they won't run. Additionally, make sure your dll is included in the Binary table, and that your custom actions reference that binary.

梦里寻她 2024-11-05 17:16:17

我模拟了该问题,并在尝试编译自定义操作类库时出现以下错误:
已添加具有相同密钥的项目。
所以这意味着在类库中不可能使用同名的方法,或者至少我们不应该这样做。

I've simulated the problem and got following errors while trying to compile the custom actions class library:
An item with the same key has already been added.
So that means it is impossible to use methods with same names in the class library, or at least we shouldn't do that.

浅暮の光 2024-11-05 17:16:16

更好的做法是:

1)尽可能消除 CA(不要重新发明轮子)
2)使CA具有通用性和声明性(表数据驱动)
3)尽可能使CA具有事务性(支持回滚)
4) 不要使用InstallUtil,而是使用WiX DTF
5) 了解自定义操作上下文/调度问题

A better practice would be to:

1) Eliminate CA's where possible ( don't reinvent the wheel )
2) Make CA's generic and declarative ( table data driven )
3) Make CA's that are transactional whenever possible ( support rollback )
4) Don't use InstallUtil, use WiX DTF instead
5) Understand custom action context / scheduling concerns

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