Skip to content

fix(windows): 应用内更新时沿用已注册的安装范围 - #2486

Merged
vastsa merged 1 commit into
vastsa:mainfrom
ZedingZhang:fix/nsis-update-install-scope
Nov 21, 2026
Merged

vastsa merged 1 commit into
vastsa:mainfrom
ZedingZhang:fix/nsis-update-install-scope

Conversation

@ZedingZhang

Copy link
Copy Markdown
Contributor

修复

Closes #2459

Windows 用户点击「退出并安装」后,如果只有一套已注册的安装,NSIS 直接沿用其范围和目录。所有用户安装继续走 electron-builder 自带的 UAC 提权流程。首次安装、手动重装和两种范围并存时仍显示范围选择页,显式传入的范围参数仍优先。

改动位于 assisted installer 的 customInstallMode 钩子。安装器在初始化时已经读取 HKLM 和 HKCU,因此可以直接使用检测结果。

验证

  • 自动更新、缓存和更新控制器的 17 个现有测试通过。
  • 使用锁定的 electron-builder 26.15.3、项目打包配置和最小测试载荷生成了 Windows x64 NSIS 安装包。
  • 在隔离 Wine 环境中,以 --updated --force-run 启动安装包。基线版本在只有 HKLM 安装时仍弹出选择页。修复后,仅有 HKLM 或仅有 HKCU 安装时直接进入安装进度页。两者并存、两者皆无,以及手动重装时均显示选择页。
  • 单独验证目标目录时,对同一安装包使用应用可执行文件名,以跳过 Wine 下误报的进程占用检查。两种范围都将测试载荷写入各自注册的目录,SHA-256 与原文件一致。
  • 新增的 NSIS 范围回归测试覆盖 8 种输入。基线行为在首个单范围用例失败,修复后全部通过。pnpm docs:check 和 pnpm check:pr-base 通过。

验证基于 48a65582678e 上的提交 7d0f4ab62837。原生 Windows 上的非管理员 UAC 提示和完整桌面应用的下载、重启流程尚未实测。

@aiuo-codepilot aiuo-codepilot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AIUO CodePilot · Preliminary review

Diff-only preliminary review of the Windows NSIS install-scope reuse change. The assisted-installer macro and the NSIS regression harness look internally consistent with the stated single-scope update behavior. One defect is evidenced in the new test harness: `!define isUpdated '$updated == "1"'` makes `${isUpdated}` expand to an NSIS `If` comparison string rather than an existing `isUpdated` definition, so the test cannot faithfully exercise the macro the way the assisted installer defines it and may silently test a tautology or fail to compile as intended.

  • medium apps/desktop/test/nsis\-update\-scope\.nsi:18: The test redefines `${isUpdated}` as the string `$updated == "1"`, which is not the assisted installer's existing `isUpdated` definition used by `installer.nsh`. As written, `${If} ${isUpdated}` expands to `${If} $updated == "1"`, so the test substitutes its own comparison for the real macro contract instead of providing the boolean condition the production hook expects. This can make the regression suite pass without exercising the actual `isUpdated` semantics and masks whether the hook works under electron-builder's real definitions.
    Evidence: \!define isUpdated '$updated == "1"'

Head: 7d0f4ab
Base: 48a6558
CI: no-statuses; mergeable: true.

Validation: code/tests NOT EXECUTED. Diff-only preliminary analysis; not approval. Human review and repository gates remain required.

@vastsa
vastsa merged commit 8a2c01c into vastsa:main Nov 21, 2026
6 checks passed
@ZedingZhang
ZedingZhang deleted the fix/nsis-update-install-scope branch November 21, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Windows 应用内更新时每次都重新询问安装范围(已是所有用户安装仍弹「为哪位用户安装该应用?」)

2 participants