WiX 中的自定义操作方法调用
假设我已经编写了一个自定义操作托管类库,我计划在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您永远不应该真正使用自定义操作来安装东西,因为这就是整个 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.
我模拟了该问题,并在尝试编译自定义操作类库时出现以下错误:
已添加具有相同密钥的项目。
所以这意味着在类库中不可能使用同名的方法,或者至少我们不应该这样做。
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.
更好的做法是:
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