首页 > 解决方案 > 如何在安装程序中可靠地检测已安装的 Net Core 3.1.x Windows 桌面运行时版本

问题描述

以下答案建议进行目录搜索以检测已安装的 Net Core 3.1.x Windows 桌面运行时:How to detect net core 3.1 windows desktop app runtime is installed

例如,以下代码检测 32 位 Net Core 桌面运行时的 3.1.4 版本:

    <!-- check for 32-bit runtime -->
    <util:DirectorySearch
          Id="NetCoreDesktopSearch"
          Variable="NetCoreDesktopInstalled"
          Path="[ProgramFilesFolder]dotnet\shared\Microsoft.WindowsDesktop.App\3.1.4"
          Result="exists"
    />

这工作了一段时间,但随着最近的更新(可能是 Windows 更新到更高的运行时版本,即版本 3.1.14),似乎有些机器的“3.1.4”文件夹已经消失,而实际的桌面运行时版本为 3.1。 4 保持安装状态(即显示为dotnet --info)。因此,安装程序可能会尝试再次运行 .Net Core Desktop 3.1.4 安装程序,这又会失败并出现错误0x80070666 - Another version of this product is already installed.并中止安装。

DirectorySearch因此不是检测特定版本的可靠方法。

有没有更好的办法?

如果系统上存在较新版本,是否可以指示官方 .Net Core Desktop 安装程序静默成功?

是否有官方认可的方法来检测安装程序中的特定 .Net Core 桌面版本(即注册表搜索)?

标签: wix.net-core-3.1

解决方案


推荐阅读