且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在安装 Windows 安装程序包之前检查先决条件是否已安装

更新时间:2023-11-26 21:31:22

更新,因为您想使用 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.


链接: