C# 尽管WIX安装失败,Word加载项仍会安装
使用WIX工具集v3.10.3.3007创建安装程序以安装MS Word加载项。如何确保故障进行完全回滚 我正在向WIX对话框序列中注入一个自定义操作,以检查用户输入的值。如果检查失败,我希望安装失败我有明确触发故障的条件,但即使触发了故障,外接程序仍会安装并运行。故意故障会弹出预期对话框,说明: ..安装向导因错误而提前结束。您的系统尚未修改 除此之外,我的系统已被修改。以下是我认为你需要看到的。我是一名WIX新手,因此我不确定是否遗漏了相关内容: 安装日志:C# 尽管WIX安装失败,Word加载项仍会安装,c#,wix,office-addins,C#,Wix,Office Addins,使用WIX工具集v3.10.3.3007创建安装程序以安装MS Word加载项。如何确保故障进行完全回滚 我正在向WIX对话框序列中注入一个自定义操作,以检查用户输入的值。如果检查失败,我希望安装失败我有明确触发故障的条件,但即使触发了故障,外接程序仍会安装并运行。故意故障会弹出预期对话框,说明: ..安装向导因错误而提前结束。您的系统尚未修改 除此之外,我的系统已被修改。以下是我认为你需要看到的。我是一名WIX新手,因此我不确定是否遗漏了相关内容: 安装日志: ...MSI (c) (E8:8
...MSI (c) (E8:8C) [18:09:07:125]: Doing action: ActivateCustomAction
MSI (c) (E8:8C) [18:09:07:125]: Note: 1: 2205 2: 3: ActionText
Action 18:09:07: ActivateCustomAction.
Action start 18:09:07: ActivateCustomAction.
MSI (c) (E8:30) [18:09:07:127]: Invoking remote custom action. DLL: C:\Users\tekhe\AppData\Local\Temp\MSIC0B9.tmp, Entrypoint: RegisterAddIn
SFXCA: Extracting custom action to temporary directory: C:\Users\tekhe\AppData\Local\Temp\MSIC0B9.tmp-\
SFXCA: Binding to CLR version v4.0.30319
Calling custom action RegisterAddIn!RegisterAddIn.CustomActions.RegisterAddIn
Begin CustomAction1
CustomAction ActivateCustomAction returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 18:09:07: ActivateCustomAction. Return value 3.
MSI (c) (E8:8C) [18:09:07:347]: Doing action: FatalError
MSI (c) (E8:8C) [18:09:07:347]: Note: 1: 2205 2: 3: ActionText
Action 18:09:07: FatalError.
Action start 18:09:07: FatalError.
Action 18:09:07: FatalError. Dialog created
Action ended 18:14:08: FatalError. Return value 2.
Action ended 18:14:08: INSTALL. Return value 3.
MSI (c) (E8:8C) [18:14:08:137]: Destroying RemoteAPI object.
MSI (c) (E8:A8) [18:14:08:137]: Custom Action Manager thread ending.
...
自定义操作:
using System;
using Microsoft.Deployment.WindowsInstaller;
namespace RegisterAddIn
{
public class CustomActions
{
[CustomAction]
public static ActionResult RegisterAddIn(Session session)
{
try
{
session.Log("Begin CustomAction1");
string token = session["ActivationToken"];
if (token == null)
{
throw new Exception("No token set yet");
}
if (token == "fail it")
{
return ActionResult.Failure;
}
session.Log("Captured activation token = " + session["ActivationToken"]);
return ActionResult.Success;
}
catch (Exception e)
{
session.Log(e.Message);
return ActionResult.Failure;
}
}
}
}
Product.wxs的一部分CustomInstallDir
是标准WIXWixUI\u InstallDir.wxs
标记的副本,添加了我的自定义操作
<Binary Id="RegisterAddIn" SourceFile="$(var.RegisterAddIn.TargetDir)RegisterAddIn.CA.dll" />
<CustomAction Id="ActivateCustomAction"
BinaryKey="RegisterAddIn"
DllEntry="RegisterAddIn"
Execute="immediate"
Return="check" />
<InstallUISequence>
<Custom Action="ActivateCustomAction" After="ExecuteAction" />
</InstallUISequence>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<!--<MediaTemplate/>-->
<Media Id="1" Cabinet="VTSAddin.cab" EmbedCab="yes"/>
<Feature Id="ProductFeature" Title="Word Add In" Level="1">
...Component Refs elided
</Feature>
<UIRef Id="CustomInstallDir" />
自定义对话框xml(TokenPromptDialog.wxs
)
1.
1.
通常故障会回滚当前安装,我在PowerPoint加载项中体验到了这一点。确保回滚执行的最简单方法是(刷新)查看控制面板中的程序和功能列表。如果您的应用程序列在那里,则表示没有发生回滚。你能确认一下吗?我能确认它在那里。我一直在卸载它从那里反复,因为我试图找出问题。文档说明应该发生回滚,最后的对话框说“系统尚未修改”,所以我不明白。这将使强制支付注册密钥变得困难。我明白了。尝试使用这些值。它对我很有效。在WixUI_InstallDir.wxs中,将值Execute=“immediate”替换为“deffered”。在“产品:*”一节中,未解析对符号“WixAction:InstallUISequence/InstallFinalize”的引用。我将尝试在自定义对话框中执行自定义操作,而不是安排它,然后看看它是如何进行的。糟糕的是,我没有要求将标记替换为其他建议。我认为在一开始使用Wix工具集是很困难的,但随着时间的推移,它是最好的Windows installer框架之一,它为您在线/离线设计、开发和部署软件包提供了最大的灵活性。
<Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="TokenPromptDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="TokenPromptDlg" Order="1">NOT Installed</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed AND NOT PATCH</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">Installed AND PATCH</Publish>
<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI>
<Dialog Id="TokenPromptDlg"
Width="370"
Height="270"
Title="Activation">
<!-- Next, Back, Cancel, etc., buttons elided -->
<Control Id="ActivationTokenLabel"
Type="Text" X="10" Y="50" Width="250" Height="18"
Text="Enter your validation token" />
<Control Id="MyTextbox"
Type="Edit"
Property="ActivationToken"
X="10" Y="75" Width="250" Height="18" />
</Dialog>
<Publish Dialog="TokenPromptDlg"
Control="Back"
Event="NewDialog"
Value="InstallDirDlg" Order="1">1</Publish>
<Publish Dialog="TokenPromptDlg"
Control="Next"
Event="NewDialog"
Value="VerifyReadyDlg" Order="1">1</Publish>
</UI>
</Fragment>
</Wix>