托管代码自定义操作存在一些问题。我有3个自定义操作,但只有其中一个正在运行。它们在InstallExecuteSequence中的不同时间被调用,但移动它们没有区别。我知道没有走得太远,因为如果我在例程的开头放置一个消息框(用于调试),它永远不会被调用。我哪里错了?这些动作就是这样创建的。
<Binary Id="CA" SourceFile="$(var.ca.Custom.Actions.TargetDir)$(var.ca.Custom.Actions.TargetName).CA.dll" />
<CustomAction Id="WriteRemoveArpEntry" Property="CustomActionData" Value="PNAME=$(var.ProductName)" HideTarget="yes" />
<CustomAction Id="RemoveArpEntry" BinaryKey="CA" DllEntry="RemoveProductFromARP" Return="ignore" />
<CustomAction Id="SetValueforProductFolder" Property="CustomActionData" Value="SDIR=[INSTALLDIR];TDIR=[MANUDIR]\backup\$(var.ProductName)\$(var.VersionNumber)" HideTarget="yes" />
<CustomAction Id="Backup_Product_DIR" BinaryKey="CA" DllEntry="BackupDIR" Return="ignore" />
<CustomAction Id="WriteInstallAttemptData" Property="CustomActionData" Value="PRODUCTNAME=$(var.ProductName);APPVERSION=$(var.VersionNumber)" HideTarget="yes" />
<CustomAction Id="WriteInstallAttempt" BinaryKey="CA" DllEntry="WriteXMLServer" Return="ignore" />
然后我在这里打电话给他们
<Custom Action="SetValueforProductFolder" Before="Backup_Product_DIR">NOT Installed AND NOT REMOVE</Custom>
<Custom Action="Backup_Product_DIR" Before="InstallFinalize">NOT Installed AND NOT REMOVE</Custom>
<Custom Action="WriteRemoveArpEntry" Before="InstallFinalize">NOT Installed AND NOT REMOVE</Custom>
<Custom Action="RemoveArpEntry" After="WriteRemoveArpEntry">NOT Installed AND NOT REMOVE</Custom>
<Custom Action="WriteInstallAttemptData" After="InstallFinalize">NOT Installed AND NOT REMOVE</Custom>
<Custom Action="WriteInstallAttempt" After="WriteInstallAttemptData">NOT Installed AND NOT REMOVE</Custom>
</InstallExecuteSequence>
例程的标题看起来像这样
public static ActionResult BackupDIR(Session session)
{
public static ActionResult RemoveProductFromARP(Session session)
{
Public static ActionResult WriteXMLServer(Session session)
{
但是只有WriteXMLServer可以工作。在日志文件中,我得到以下内容。
MSI(BC:9C)[07:23:45:562]:调用远程自定义操作。 DLL: C:\ Windows \ Installer \ MSI2E2A.tmp,入口点:BackupDIR CustomAction Backup_Product_DIR返回实际的错误代码1154,但将是 由于继续标记而转化为成功
在有效的那个我得到
MSI(s)(BC:A0)[07:24:25:994]:调用远程自定义操作。 DLL: C:\ Windows \ Installer \ MSICC20.tmp,入口点:WriteXMLServer SFXCA: 将自定义操作提取到临时目录: C:\ Windows \ Installer \ MSICC20.tmp- \ SFXCA:绑定到CLR版本 v4.0.30319
答案 0 :(得分:1)
答案非常简单,我忘记了
[CustomAction]
对于其他两个例程。