MSI:如何仅在未安装另一个组件的情况下安装一个组件

发布于 2024-11-04 00:54:54 字数 357 浏览 0 评论 0原文

我的应用程序涉及一个可选组件,其快捷方式取代了默认安装提供的快捷方式。如果未安装此可选附加功能,我不知道如何使其仅安装默认快捷方式 - 或者我只需要给它们提供相同的名称并希望得到最好的结果?这需要通过自定义安装树以及常规按钮来完成。

看看它的工作方式是,如果在安装时选择了这一额外功能,则主应用程序的“开始”菜单快捷方式必须指向此快捷方式,这将在需要时自行打开主应用程序。

我正在使用InstallShield 2011 Professional。

编辑: 澄清 - 我确实将它分为三个组件:主程序、主程序的快捷方式和带快捷方式的插件。我只是不知道如何检查插件是否已经/正在安装,以便我可以将其置于主快捷方式的条件中。当然有一个变量吗?该文档非常简洁。

My application involves an optional component with shortcuts that supersede the shortcuts provided by the default install. I can't figure out how to make it only install the default shortcuts if this optional extra is not installed - or do I just need to give them both the same name and hope for the best? This needs to work through the Custom Installation tree as well as the regular buttons.

See the way it works is, if this extra selected on install, the Start Menu shortcuts for the main application have to instead point to this one, which will open the main one on its own when it needs to.

I'm using InstallShield 2011 Professional.

EDIT:
to clarify -
I do have it as three components: main, main's shortcut, and addon with shortcut. I just don't know how to check if the addon one has been/is being installed in a way that I can put it in a condition for main's shortcut. Surely there's a variable for it? The documentation is very spartan.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

别闹i 2024-11-11 00:54:54

如果我正确理解了这个问题,除非安装了 MIDDLEMAN.EXE,否则 MAIN.EXE 会获得快捷方式。在这种情况下,MIDDLEMAN.EXE 会获得快捷方式。

这是一个奇怪的问题,因为一个组件的存在改变了另一个组件的定义。尽管如此,它还是可以做到的。我的方法是为 MIDDLEMAN.EXE 创建一个组件并定义它的快捷方式。为 MAIN.EXE 创建另一个组件,并且不定义它的快捷方式。

然后编写一个自定义操作,该操作在文件成本计算后立即执行的执行序列中运行。让它检查 MIDDLEMAN.EXE 是否未安装以及是否正在安装。如果是这样,请将临时行写入快捷方式表以定义 MAIN.EXE 的快捷方式。

从那里,您可以让 MSI 处理其余的事情,而无需延迟自定义操作来处理快捷方式的服务。

尽管如此,我还是忍不住想知道这是否不能通过更改应用程序的设计来简化。基本上,您尝试在 EXE 级别进行依赖项注入,并且在 DLL 级别完成此操作会更容易。换句话说:

带有 ShortCut 的 MAIN.EXE
可选DLL

MAIN.EXE 总是被调用,但当Optional.DLL 存在时,他的行为会有所不同。

If I'm understanding the question correctly, MAIN.EXE gets a shortcut unless MIDDLEMAN.EXE is getting installed. In which case MIDDLEMAN.EXE gets the shortcut.

This is an odd problem in that the existance of a component changes the definition of another component. Still, it can be done. The way I would do it is create a component for MIDDLEMAN.EXE and define it's shortcut. Create another component for MAIN.EXE and don't define it's shortcut.

Then write a custom action that runs in the execute sequence in immeadiate execution that runs after file costing. Have it check to see if MIDDLEMAN.EXE is not installed and not being installed. If this is true, have a write a temporary row to the ShortCut table to define the ShortCut for MAIN.EXE.

From there you can let MSI handle the rest without the need for deferred custom actions to handle servicing the shortcut.

Still, I can't help wondering if this couldn't be simplified by changing the design of the application. Basically you are trying to do dependency injection at the EXE level and it would be easier to accomplish this at the DLL level. In otherwords:

MAIN.EXE with ShortCut
Optional DLL

The MAIN.EXE is always called but he will behave differently when Optional.DLL is present.

枉心 2024-11-11 00:54:54

假设安装中包含默认组件,您可以为“额外”组件使用组件条件。然后,您可以确保仅当其他组件未安装时才安装此额外组件,即它们相互排斥。这将避免任何混乱的功能,使您的自定义对话框变得更加复杂。

Assuming the default component is included in the installation, you can probably use a component condition for your 'extra' component. You can then make sure that this extra component is installed only if the other component isn't, i.e. they become mutually exclusive. This will avoid any messing about with features that would make your Custom dialog much more complicated.

别靠近我心 2024-11-11 00:54:54

@Stephen:我不明白如何避免使用功能,因为只有功能在 GUI 中对用户可见,因此允许用户指定要安装的内容?

我通常不喜欢这种解决方案,因为它不会根据 MSI 文件的内部一致性检查器进行验证,但您可以将 EXE 安装在一个组件中,然后拥有两个组件,每个组件具有不同的快捷方式,您可以将这些快捷方式设置为相互可用独家的。然后,您将自定义快捷方式组件附加到触发安装自定义快捷方式的功能。该功能必须在 GUI 中设置为可见。快捷方式必须是非广告的,因为它们位于没有文件的组件中。您可能需要在快捷方式组件上设置瞬态标志,以允许删除/添加正确的组件以进行维护安装。在维护安装期间,瞬态组件会重新评估其组件条件,以检查为其指定的条件是否会触发删除/添加。

@Stephen: I can't see how you can avoid using features since only features are visible to the user in the GUI and hence allows the user to specify what to install?

I generally don't like this kind of solution since it doesn't validate according to internal consistency checkers for MSI files, but you can install the EXE in one component, and then have two components each with different shortcuts that you condition to be mutually exclusive. You then attach the customized shortcut component to the feature which triggers the custom shortcuts to be installed. The feature must be set visible in the GUI. The shortcuts must be non-advertised since they are in components without files. You may need to set the transient flag on the shortcut components to allow removal / addition of the right component for maintenance installs. Transient components have their component-conditions re-evaluated during maintenance installs to check if the conditions specified for them will trigger removal / addition.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文