MSI 安装程序扩展如何定位另一个应用程序的安装目录? [英] How can an MSI installer extension locate the installation directory of another application?

查看:28
本文介绍了MSI 安装程序扩展如何定位另一个应用程序的安装目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个支持插件的主应用程序 TheApp.默认情况下,应用程序 A 安装在 $(ProgramFiles)\TheApp,但金牌所有者希望这是用户可自定义的,因此其位置可能会根据用户在安装时的输入而有所不同.

I have a main application TheApp which supports plugins. Application A is installed by default at $(ProgramFiles)\TheApp, but the gold-owners want this to be user-customizable, so its location may vary depending on user input at installation time.

插件通过将它们复制到安装目录下的子目录Packages 来安装.具体来说,不需要为要加载的包设置注册表设置,我正在尝试尽可能地远离注册表.当然,如果用户在安装 TheApp 时更改了安装目录,插件也必须更改其安装位置以匹配.

Plugins are installed by copying them to a subdirectory Packages under installation directory. Specifically, no registry settings need to be set for a package to load, and I'm trying to stay out of the registry as much as possible. Naturally, if the user changed the installation directory when installing TheApp, the plugins must also change their installation location to match.

这是如何最好地完成的?我不擅长使用 WiX 编写 MSI 安装程序,但我的第一次尝试可能是在安装 TheApp 时创建一个注册表项,保存其安装位置,然后让插件搜索注册表项.这迫使我创建注册表值,这是我尽可能避免的.然而,令我震惊的是安装程序应该能够利用 Windows Installer 数据库来定位 TheApp 的安装目录.这将消除对注册表项的需要.

How is this best accomplished? I'm not seasoned at writing MSI installers with WiX, but my first attempt would probably be to create a registry key when TheApp is installed saving its install location, and then have the plugins search for the registry key. This forces me to create registry value, which is what I'm trying to avoid if possible. However, it strikes me that the installer should be able to take advantage of the Windows Installer database to locate the TheApp's installation directory. That would remove the need for a registry entry.

是否有关于如何进行安装程序间通信的最佳实践",特别是安装目录?如果两个安装程序都使用 WiX 编写,那么通信会是什么样子?

Is there a "best practice" for how to do this inter-installer communication, specifically the installation directory? How would the communication look like, given that both installers will be written in WiX?

推荐答案

是的,您可以使用 Windows Installer 数据库,并且在某些情况下,无需自定义操作!

Yes, you can use the Windows Installer database and, under certain conditions, without a custom action!

标准表和操作支持搜索已安装的组件.因此,如果您的应用程序目录中安装了某个组件(例如,您的应用程序 .exe)并且您提供了固定的 GUID,则您的插件安装程序可以找到它.

The standard tables and actions support searching for installed components. So, if your app directory has a certain component installed in it (e.g, your app .exe) that you give a fixed GUID, your plugin installer can find it.

由于您在所有项目中都需要MainComponentGuid",请将其作为 define 提取到 Include 文件中.

Since you'll need the "MainComponentGuid" in all projects, extract it out as a define in an Include file.

插件制作:

<?include ../MainSetup/MainComponentGuid.wxi?>

<Property Id="MAINDIR">
  <ComponentSearch Id="MainComponentSearch" Type="file" Guid="$(var.MainComponentGuid)">
    <DirectorySearch Id="MainComponentDirectorySearch" AssignToProperty="yes"  Depth="0" />
  </ComponentSearch>
</Property>

<CustomAction Id="SetInstallFolder" Directory="INSTALLFOLDER" Value="[MAINDIR]" />
<InstallExecuteSequence>
  <Custom Action="SetInstallFolder" After="CostFinalize">NOT Installed</Custom>
</InstallExecuteSequence>

在您的目录结构中,您可以将 Packages 设为 INSTALLFOLDER 的子项.您也可以在 LaunchCondition 中使用 MAINDIR 来防止安装插件,除非安装了主要产品.

In your Directory structure, you'd make Packages a child of INSTALLFOLDER. You might also use MAINDIR in a LaunchCondition to prevent installing a plugin unless the main product is installed.

这篇关于MSI 安装程序扩展如何定位另一个应用程序的安装目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆