Skip to content

Refactor installer upgrade logic using MajorUpgrade element#3

Merged
zzy-life merged 1 commit intomasterfrom
claude/fix-msi-data-inheritance-G1hXa
Jan 23, 2026
Merged

Refactor installer upgrade logic using MajorUpgrade element#3
zzy-life merged 1 commit intomasterfrom
claude/fix-msi-data-inheritance-G1hXa

Conversation

@zzy-life
Copy link
Copy Markdown
Owner

Summary

Replaced the manual upgrade detection and removal logic with WiX's built-in MajorUpgrade element, simplifying the installer configuration and improving upgrade handling.

Key Changes

  • Removed manual Property and Upgrade elements that detected previous installations
  • Replaced with MajorUpgrade element configured to:
    • Prevent downgrades with a localized Chinese error message
    • Schedule removal after install execution
    • Allow same-version reinstalls
  • Removed explicit RemoveExistingProducts custom action from InstallExecuteSequence (now handled automatically by MajorUpgrade)

Implementation Details

The MajorUpgrade element is the recommended WiX approach for handling major version upgrades. It automatically manages:

  • Detection of previous product versions
  • Removal of existing installations during upgrade
  • Version comparison and downgrade prevention

The Schedule="afterInstallExecute" attribute ensures new files are installed before removing the old version, reducing downtime during upgrades. The AllowSameVersionUpgrades="yes" setting enables repair/reinstall scenarios.

修改内容:
1. 使用 MajorUpgrade 替代旧的 Upgrade + RemoveExistingProducts 组合
2. 设置 Schedule="afterInstallExecute" 确保新版本先安装完成再卸载旧版本
3. 添加 AllowSameVersionUpgrades="yes" 支持同版本覆盖安装
4. 添加中文降级错误提示信息

技术细节:
- 旧策略使用 RemoveExistingProducts Before="InstallInitialize",会在安装新版本前先卸载旧版本
- 新策略使用 MajorUpgrade Schedule="afterInstallExecute",先安装新版本再卸载旧版本
- 用户数据保存在 HKCU\Software\Sand Soft\Desktop Notes,在升级过程中会被完整保留
- 这是 WiX 推荐的最佳实践,提供更安全可靠的升级体验

https://claude.ai/code/session_01JbJbLZrdhMn7p28mbyxdoX
@zzy-life zzy-life merged commit e06f71c into master Jan 23, 2026
1 check passed
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.

2 participants