问题
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?
回答1:
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
回答2:
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.
回答3:
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.
来源:https://stackoverflow.com/questions/5516100/custom-action-method-calls-in-wix