【发布时间】:2012-11-14 21:17:45
【问题描述】:
我在未执行 Wix 自定义操作时遇到问题。即使自定义操作返回 ActionResult.Success,安装程序也会不断自行回滚。
自定义操作 (C#)
[CustomAction]
public static ActionResult SetPermissionsToAppDataFolder(Session session)
{
return ActionResult.Success;
}
Wix 中的自定义操作定义
<!-- Custom Action -->
<Binary Id="CustomActionLibrary" SourceFile="$(var.CustomActionFolder)InstallerCustomActions.CA.dll" />
<CustomAction Id="CustomActionInstallDirectoryPermission"
BinaryKey="CustomActionLibrary"
DllEntry="SetPermissionsToAppDataFolder"
Execute="deferred"
Return="check" />
安装序列调用自定义操作
<!-- Install Sequences -->
<InstallExecuteSequence>
<Custom Action="CustomActionInstallDirectoryPermission" Before="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>
安装程序编译良好,因此找到自定义操作库文件没有问题。问题是安装程序在回滚之前进入了安装的最后阶段。当我们在安装序列中删除对自定义操作的调用时,安装程序完成。
据我了解,自定义操作 CA.dll 会嵌入到最终安装程序中。最初我认为 CA.dll 需要与安装程序一起分发,但后来发现安装程序会将其编译成最终的 .msi。
我已经使用以下代码“连接”了自定义操作库: http://www.codeproject.com/Articles/132918/Creating-Custom-Action-for-WIX-Written-in-Managed
无论我做什么,我都无法完成安装程序,即使自定义操作返回“成功”也是如此。任何帮助表示赞赏。
【问题讨论】:
-
执行
msiexec /i yourinstaller.msi /l log.txt并在生成的输出log.txt文件中查找任何错误。 -
是否会相对于安装程序创建日志文件?
-
日志文件将在执行
msiexec的目录中创建。可能是C:\Users\Rupert Puxton\Documents\Visual Studio 2010\Projects\My Project\Installer\bin\Release之类的东西,或者类似的东西。
标签: c# installation wix custom-action