Skip to content

Commit 52a7086

Browse files
fix(packaging/windows): Allow WiX installer downgrades across builds
Update Windows WiX packaging to better support users switching between release and PR builds. This adds `CPACK_WIX_PROPERTY_REINSTALLMODE` (`amus`) so files are replaced regardless of embedded file version, and introduces a custom WiX template with `<MajorUpgrade AllowDowngrades="yes">` instead of CPack's default downgrade-blocking behavior.
1 parent 9d2409f commit 52a7086

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

cmake/packaging/windows_wix.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ set(CPACK_WIX_HELP_LINK "https://docs.lizardbyte.dev/projects/sunshine/latest/md
6464
set(CPACK_WIX_PRODUCT_ICON "${SUNSHINE_ICON_PATH}")
6565
set(CPACK_WIX_PRODUCT_URL "${CMAKE_PROJECT_HOMEPAGE_URL}")
6666
set(CPACK_WIX_PROGRAM_MENU_FOLDER "LizardByte")
67+
# Force package files to replace existing files when switching between release
68+
# and PR builds, regardless of their embedded file versions.
69+
# https://learn.microsoft.com/en-us/windows/win32/msi/reinstallmode
70+
set(CPACK_WIX_PROPERTY_REINSTALLMODE "amus")
6771

6872
set(CPACK_WIX_EXTENSIONS
6973
"WixToolset.UI.wixext"
@@ -82,6 +86,12 @@ set(CPACK_WIX_EXTRA_SOURCES
8286
set(CPACK_WIX_PATCH_FILE
8387
"${WIX_BUILD_PARENT_DIRECTORY}/patch.xml"
8488
)
89+
# CPack's default WiX template blocks downgrades. Sunshine users commonly switch
90+
# between release and PR builds, so allow any build to replace the installed one.
91+
# https://docs.firegiant.com/wix/schema/wxs/majorupgrade/#allowdowngrades
92+
set(CPACK_WIX_TEMPLATE
93+
"${WIX_BUILD_PARENT_DIRECTORY}/wix.template.in"
94+
)
8595

8696
# Copy root LICENSE and rename to have .txt extension
8797
file(COPY "${CMAKE_SOURCE_DIR}/LICENSE"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?include "cpack_variables.wxi"?>
4+
5+
<Wix
6+
xmlns="http://wixtoolset.org/schemas/v4/wxs"@CPACK_WIX_CUSTOM_XMLNS_EXPANDED@
7+
RequiredVersion="4.0"
8+
>
9+
<Package
10+
Name="$(var.CPACK_PACKAGE_NAME)"
11+
Version="$(var.CPACK_PACKAGE_VERSION)"
12+
Manufacturer="$(var.CPACK_PACKAGE_VENDOR)"
13+
UpgradeCode="$(var.CPACK_WIX_UPGRADE_GUID)"
14+
ProductCode="$(var.CPACK_WIX_PRODUCT_GUID)"
15+
Scope="$(var.CPACK_WIX_INSTALL_SCOPE)"
16+
InstallerVersion="500"
17+
Language="1033"
18+
Compressed="yes"
19+
>
20+
<?ifndef CPACK_WIX_CAB_PER_COMPONENT?>
21+
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes"/>
22+
<?endif?>
23+
24+
<MajorUpgrade
25+
Schedule="afterInstallInitialize"
26+
AllowDowngrades="yes"/>
27+
28+
<WixVariable Id="WixUILicenseRtf" Value="$(var.CPACK_WIX_LICENSE_RTF)"/>
29+
<Property Id="WIXUI_INSTALLDIR" Value="INSTALL_ROOT"/>
30+
31+
<?ifdef CPACK_WIX_PRODUCT_ICON?>
32+
<Property Id="ARPPRODUCTICON" Value="ProductIcon.ico" />
33+
<Icon Id="ProductIcon.ico" SourceFile="$(var.CPACK_WIX_PRODUCT_ICON)"/>
34+
<?endif?>
35+
36+
<?ifdef CPACK_WIX_UI_BANNER?>
37+
<WixVariable Id="WixUIBannerBmp" Value="$(var.CPACK_WIX_UI_BANNER)"/>
38+
<?endif?>
39+
40+
<?ifdef CPACK_WIX_UI_DIALOG?>
41+
<WixVariable Id="WixUIDialogBmp" Value="$(var.CPACK_WIX_UI_DIALOG)"/>
42+
<?endif?>
43+
44+
<FeatureRef Id="ProductFeature"/>
45+
<ui:WixUI Id="$(var.CPACK_WIX_UI_REF)" />
46+
<UIRef Id="WixUI_ErrorProgressText" />
47+
48+
<?include "properties.wxi"?>
49+
<?include "product_fragment.wxi"?>
50+
</Package>
51+
</Wix>

0 commit comments

Comments
 (0)