如何确保在安装两个组件之间触发自定义操作?
例如,我有一些如下的Wix定义:
<Feature Id="ProductFeature" Title="My Installer" Level="1">
<ComponentGroupRef Id="DatabaseSetup" />
<ComponentGroupRef Id="DatabaseCleanup" />
</Feature>
<InstallExecuteSequence>
<Custom Action="RunDatabaseMigration" Before="InstallFinalize"></Custom>
</InstallExecuteSequence>
是否有办法确保自定义操作RunDatabaseMigration
在DatabaseSetup
和DatabaseCleanup
之间正确运行?
我期望这样,但是很明显,我只能对“ Before and After”属性使用标准或自定义操作的名称,此解决方案不适用于组件。
<Custom Action="RunDatabaseMigration" After="DatabaseSetup"></Custom>
答案 0 :(得分:3)
How to make sure a custom action to be triggered between installation of two components?
In general is not possible to schedule a custom action between two components. As you already found out by yourself, the Before
and After
attributes have to name a standard or custom action.
Windows installer doesn't install one component after another. Components are just logical groups of installation items, e. g. registry keys, files and so on but they don't define installation order. Instead, Windows installer groups different kind of resources like registry keys and files and installs these groups in the order defined by the InstallExecuteSequence
table. For instance, at one point all files will be installed (InstallFiles
action) and later on all registry keys will be written (WriteRegistryValues
). Have a look at the suggested InstallExecuteSequence
换成了更好的主意。
话虽这么说,如果DatabaseSetup
仅安装一种资源(例如文件),而DatabaseCleanup
安装另一种资源(例如注册表项),则可以在两个关联的标准之间安排自定义操作操作(在这种情况下为InstallFiles
和WriteRegistryValues
)。但是,如果两个组件都安装相同类型的资源或混合资源,则不能使用该替代方法。在这种情况下,您必须将其中一个组件转换为可以随时计划的自定义操作。