【问题标题】:Run .NET 2.0 console application in WiX custom action from binary table在二进制表的 WiX 自定义操作中运行 .NET 2.0 控制台应用程序
【发布时间】:2012-03-13 21:38:36
【问题描述】:

我正在尝试在我的 WiX MSI 设置项目中以自定义操作运行用 C# .NET 2.0 编写的控制台应用程序,如下所示:

<CustomAction Id="INSTALL_TEXT" Impersonate="yes" Return="check" Execute="immediate" BinaryKey="TextCreator.exe" ExeCommand="C:\test.txt -i"/>
<CustomAction Id="UNINSTALL_TEXT" Impersonate="yes" Return="check" Execute="immediate" BinaryKey="TextCreator.exe" ExeCommand="C:\test.txt -u"/>
<Binary Id="TextCreator.exe" SourceFile="C:\MyInstaller\Test\Tools\TextCreator.exe"/>
<InstallExecuteSequence>
  <Custom Action="INSTALL_TEXT" After="InstallFiles">NOT Installed AND NOT PATCH</Custom>
  <Custom Action="UNINSTALL_TEXT" After="RemoveFiles">Installed AND REMOVE="ALL"</Custom>
</InstallExecuteSequence>

但我总是在日志中收到一条错误消息:

MSI (s) (7C:C0) [14:03:01:026]: 注意: 1: 1721 2: INSTALL_TEXT 3: C:\Windows\Installer\MSI9938.tmp 4: C:\test.txt -i
错误 1721。此 Windows 安装程序包有问题。无法运行完成此安装所需的程序。请联系您的支持人员或软件包供应商。操作:INSTALL_TEXT,位置:C:\Windows\Installer\MSI9938.tmp,命令:C:\test.txt -i
MSI (s) (7C:C0) [14:03:07:374]:产品:Text Creator Console App -- 错误 1721。此 Windows Installer 程序包存在问题。无法运行完成此安装所需的程序。请联系您的支持人员或软件包供应商。操作:INSTALL_TEXT,位置:C:\Windows\Installer\MSI9938.tmp,命令:C:\test.txt -i
行动于 14:03:07 结束:INSTALL_TEXT。返回值 3。

我在我的应用程序中嵌入了一个清单,以便以管理权限运行:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

当我从命令行运行安装程序时,控制台提示符已经以管理权限启动,安装和卸载都可以正常工作!但是,当我使用双击启动 MSI 时,如果我想以管理权限运行,系统会要求我运行安装(在进度条继续之前)。然后我的设置中止,并显示上面 LOG 中提供的错误消息。

是什么导致了这个问题?我在我的项目中使用带有 MSI 2.0 的 WiX 3.5.2519.0。我的设置在 Windows 7 Professional (x64) 上运行。我安装了从 2.0、3.0、3.5 到 4.0 的所有框架!

编辑:在安装了 .NET Framework 2.0 的 Windows XP 上,一切正常!

解决方案:

<CustomAction Id="QtExecInstallText" Impersonate="no" Return="check" Execute="deferred" BinaryKey="TextCreator.exe" ExeCommand="C:\test.txt -i"/>
<CustomAction Id="QtExecUninstallText" Impersonate="no" Return="check" Execute="deferred" BinaryKey="TextCreator.exe" ExeCommand="C:\test.txt -u"/>
<Binary Id="TextCreator.exe" SourceFile="C:\MyInstaller\Test\Tools\TextCreator.exe"/>
<InstallExecuteSequence>
  <Custom Action="QtExecInstallText" After="InstallFiles">NOT Installed AND NOT PATCH</Custom>
  <Custom Action="QtExecUninstallText" After="RemoveFiles">Installed AND REMOVE="ALL"</Custom>
</InstallExecuteSequence>

=> 将 pass -ext "%WIX%\bin\WixUtilExtension.dll" 链接到 light.exe 时!

【问题讨论】:

    标签: wix windows-installer custom-action


    【解决方案1】:

    在 MSI 安装程序中运行任何 EXE 的最简洁方法是使用 Quiet Execution Custom Action

    如何实现它的示例在链接页面上。 FWIW,正确安排的自定义操作(延迟没有模拟)将已经作为系统运行,并且清单/UAC 海拔将不适用。此外,如果您可以将 .NET EXE 重构为客户端/服务器 (EXE / DLL) 安排,那么您可以获取服务器类并在 Deployment Tools Foundation (DTF) 自定义操作中使用它。

    这是一个更好的设计,因为它在进程中而不是在进程外运行,并且可以调用MSI API,例如获取 CustomActionData 属性、写入 MSI 日志、返回 ErrorSuccess 和/或发布进度条更​​新和操作消息.与此相比,分叉到 EXE 文件是一种 hack。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-18
      • 1970-01-01
      • 1970-01-01
      • 2018-02-26
      • 2021-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多