在安装 Windows 安装程序包之前检查先决条件是否已安装 [英] Check if prerequisites are installed before installing a windows installer package

查看:51
本文介绍了在安装 Windows 安装程序包之前检查先决条件是否已安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 .Net 4.0 上开发的 .Net WinForms 应用程序.(Windows 安装程序包).该应用程序依赖于 SAP Crystal Report 运行时和 MS Access 运行时.我需要检查这两个先决条件是否安装在用户计算机上,如果没有,则退出安装程序并显示一个对话框,提示安装因缺少先决条件而失败.

I have a .Net WinForms application developed on .Net 4.0. (windows installer package). The application is dependent on SAP crystal report runtime and MS Access runtime. I need to check if these two prerequisites are installed on the user machine, if not then exit the installer with a dialog box saying installation failed due to missing prerequisites.

下图突出显示了我正在处理的安装程序项目的类型.这是一个旧的遗留应用程序.

The image below highlights the type of installer project that I'm working on. It is a old legacy application.

这里我创建了搜索目标机器"并创建了添加注册表搜索"-搜索Crystal Report Runtime"

Here I have created "Search Target Machine" and created "Add Registry Search" - "Search for Crystal Report Runtime"

并在启动条件"下创建了一个新的启动条件",称为CrystalReportRuntimeInstalled".不知何故,即使安装了软件,这种情况也总是评估为假.我做错了什么?

And created a new "Launch Conditions" under "Launch Conditions" called as "CrystalReportRuntimeInstalled". Somehow this condition is always evaluating to false even when the software is installed. What am i doing wrong?

推荐答案

更新,因为您想使用 WiX:

UPDATE, since you want to use WiX:

WiX 快速入门:通过查看 Helge克莱因:https://helgeklein.com/blog/2014/09/real-world-example-wix-msi-application-installer/ (WayBack - 存档版本).

还有更多WiX 快速入门建议"在这里.那包括更多的源代码示例链接和各种链接.这是临时答案"- 换句话说,凌乱 - 这似乎有助于真实世界.我仍然想知道为什么,如果你能告诉我那是不是不管是真是假都好.

There are more "WiX quick start suggestions" here. That includes more source code sample links and links of all kinds. It is an "ad-hoc answer" - in other words messy - that seems to help in the real-world. I still wonder why, if you can tell me whether that is true or not that would be good.

  • Here is a sample of the links from above: From MSI to WiX, Part 3 – Launch Conditions and Application Search (Wayback - Archived Version). Alex Shevchuk.

快速的内嵌示例:

<Condition Message="The .NET Framework 2.0 must be installed">
    Installed OR NETFRAMEWORK20
</Condition>


启动条件表:一般机制是启动条件表.您在此处添加必须满足的条件(评估为 true)才能允许安装操作(不仅仅是全新安装).您可以使用自定义操作来检查系统并设置属性,也可以使用内置的 MSI 搜索机制来设置属性.然后在指定的条件下使用这些属性.


LaunchCondition Table: The general mechanism for this is the LaunchCondition table. You add conditions here that must be satisfied (evaluate to true) for the package to allow installation operations (not just fresh install). You can use custom actions to inspect the system and set properties or you can use built-in MSI search mechanisms to set properties. The properties are then used in the condition specified.

启动条件问题:条件可能会在维护和卸载操作中意外评估为假.这通常是非常不希望的.一个例子是检查是否存在可以手动卸载的运行时,因此意外导致主 MSI 无法卸载甚至升级.此处示例(请仔细阅读).

LaunchCondition Problems: Conditions can accidentally evaluate to false on maintenance and uninstall operations. This is generally very undesirable. An example is a check for the presence of a runtime that can have been uninstalled manually and hence accidentally made the main MSI fail to uninstall or even upgrade. Example here (please read thoroughly).

调整:为了确保 LaunchConditions 仅适用于全新安装(和主要升级 - 可作为全新使用)安装),有一个技巧可以将 OR Installed" 添加到您需要的条件中.此处描述.到蝙蝠车.

示例:这是 LaunchCondition table 为例(需要 .NET 4.7 版):

Example: Here is a row from a LaunchCondition table as example (Require .NET version 4.7):

Installed OR DOTNETVERSION471FULL>="#461308", Microsoft .NET Framework 4.7.1 Full package or greater needs to be installed for this installation to continue.


链接:

这篇关于在安装 Windows 安装程序包之前检查先决条件是否已安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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