2

已尝试为我的最新项目创建WiX安装程序。我有一个奇怪的问题,如果我通过cmd提示符运行msi作为管理它工作正常,自定义操作启动没有大惊小怪,一切正常,但如果我双击msi自定义操作不起作用,安装程序失败。我使用的Visual Studio 2012,并使用Windows 7WiX msi自定义操作未在Windows 7的有限权限下运行

<!--Custom Actions--> 
<Binary Id='customShortcut' SourceFile='$(var.CustomDir)\TestInstallerCustom.CA.dll'/> 
<Binary Id='customDir' SourceFile='$(var.CustomDir)\TestInstallerCustom.CA.dll'/> 
<Binary Id='removeDir' SourceFile='$(var.CustomDir)\TestInstallerCustom.CA.dll'/> 

<CustomAction Id='customShortcutId' BinaryKey='customShortcut' DllEntry='CustomShortcut' 
       Execute='immediate' Impersonate='no' Return='check' /> 
<CustomAction Id='customDirId' BinaryKey='customDir' DllEntry='CustomDir' 
       Execute='immediate' Impersonate='no' Return='check'/> 
<CustomAction Id='removeDirId' BinaryKey='removeDir' DllEntry='RemoveDir' 
       Execute='immediate' Impersonate='no' Return='check'/> 

<InstallExecuteSequence> 
    <Custom Action='customDirId' Before='InstallFinalize'/> 
    <Custom Action='customShortcutId' After='InstallFinalize'/> 
    <Custom Action="removeDirId" After="InstallValidate">REMOVE="ALL"</Custom> 
</InstallExecuteSequence> 

回答

3

'immediate'自定义操作不是由安装高架部分执行。因此,它们只在安装过程中被抬高(如你所见)。要提高自定义操作,它们必须是交易脚本的一部分。要做到这一点,请设置CustomAction元素Execute='deferred'属性。

注意:推迟的自定义操作在MSI SDK中有其他限制:'Deferred Execution Custom Actions' topic。由于看起来自定义操作正在修改机器状态,因此您还需要考虑添加回滚自定义操作以撤消由延迟自定义操作完成的更改。

编写自定义操作很有挑战性。这是自定义操作是安装失败最大的原因之一。如果您可以避免编写自定义操作,我强烈建议您这样做。 :)

+0

感谢您的答复。网上有关于回滚自定义操作的信息吗? – user2260125 2013-04-12 00:59:38

+0

可以在http://msdn.microsoft.com/en-us/library/windows/desktop/aa371369(v=vs.85).aspx标记为“回滚自定义操作”的主题中 – 2013-04-12 03:00:22