Skip to content

Commit a6dbf17

Browse files
Refactor WiX packaging resources and update installer
Replaces custom-actions.wxs and custom-shortcuts.wxs with sunshine-installer.wxs, consolidating custom actions and shortcut definitions. Adds patch.xml for WiX patching. Updates windows_wix.cmake to use new resource files, install the WiX Util extension, and adjust build directories. This streamlines and modernizes the Windows installer packaging process.
1 parent 0f10c15 commit a6dbf17

5 files changed

Lines changed: 78 additions & 128 deletions

File tree

cmake/packaging/windows_wix.cmake

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
set(CPACK_WIX_VERSION 4)
55
set(WIX_VERSION 4.0.4)
66
set(WIX_UI_VERSION 4.0.4) # extension versioning is independent of the WiX version
7-
set(WIX_BUILD_PARENT_DIRECTORY "${CPACK_PACKAGE_DIRECTORY}/_CPack_Packages/win64")
8-
set(WIX_BUILD_DIRECTORY "${WIX_BUILD_PARENT_DIRECTORY}/WIX")
7+
set(WIX_BUILD_PARENT_DIRECTORY "${CMAKE_BINARY_DIR}/wix_packaging")
8+
set(WIX_BUILD_DIRECTORY "${CPACK_PACKAGE_DIRECTORY}/_CPack_Packages/win64/WIX")
99

1010
# Download and install WiX tools locally in the build directory
1111
set(WIX_TOOL_PATH "${CMAKE_BINARY_DIR}/.wix")
@@ -38,17 +38,31 @@ if(NOT WIX_UI_INSTALL_RESULT EQUAL 0)
3838
message(FATAL_ERROR "Failed to install WiX UI extension, error: ${WIX_UI_INSTALL_OUTPUT}")
3939
endif()
4040

41+
# Install WiX Util Extension
42+
execute_process(
43+
COMMAND "${WIX_TOOL_PATH}/wix" extension add WixToolset.Util.wixext/${WIX_UI_VERSION}
44+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
45+
ERROR_VARIABLE WIX_UTIL_INSTALL_OUTPUT
46+
RESULT_VARIABLE WIX_UTIL_INSTALL_RESULT
47+
)
48+
49+
if(NOT WIX_UTIL_INSTALL_RESULT EQUAL 0)
50+
message(FATAL_ERROR "Failed to install WiX Util extension, error: ${WIX_UTIL_INSTALL_OUTPUT}")
51+
endif()
52+
4153
# Set WiX-specific variables
4254
set(CPACK_WIX_ROOT "${WIX_TOOL_PATH}")
4355
set(CPACK_WIX_UPGRADE_GUID "512A3D1B-BE16-401B-A0D1-59BBA3942FB8")
4456

45-
# Help/Support URLs
57+
# Installer metadata
4658
set(CPACK_WIX_HELP_LINK "https://docs.lizardbyte.dev/projects/sunshine/latest/md_docs_2getting__started.html")
59+
set(CPACK_WIX_PRODUCT_ICON "${SUNSHINE_ICON_PATH}")
4760
set(CPACK_WIX_PRODUCT_URL "${CMAKE_PROJECT_HOMEPAGE_URL}")
4861
set(CPACK_WIX_PROGRAM_MENU_FOLDER "LizardByte")
4962

5063
set(CPACK_WIX_EXTENSIONS
5164
"WixToolset.UI.wixext"
65+
"WixToolset.Util.wixext"
5266
)
5367

5468
message(STATUS "cpack package directory: ${CPACK_PACKAGE_DIRECTORY}")
@@ -58,8 +72,10 @@ file(COPY "${CMAKE_CURRENT_LIST_DIR}/wix_resources/"
5872
DESTINATION "${WIX_BUILD_PARENT_DIRECTORY}/")
5973

6074
set(CPACK_WIX_EXTRA_SOURCES
61-
"${WIX_BUILD_PARENT_DIRECTORY}/custom-actions.wxs"
62-
"${WIX_BUILD_PARENT_DIRECTORY}/custom-shortcuts.wxs"
75+
"${WIX_BUILD_PARENT_DIRECTORY}/sunshine-installer.wxs"
76+
)
77+
set(CPACK_WIX_PATCH_FILE
78+
"${WIX_BUILD_PARENT_DIRECTORY}/patch.xml"
6379
)
6480

6581
# Copy root LICENSE and rename to have .txt extension

cmake/packaging/wix_resources/custom-actions.wxs

Lines changed: 0 additions & 100 deletions
This file was deleted.

cmake/packaging/wix_resources/custom-shortcuts.wxs

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<CPackWiXPatch>
2+
<CPackWiXFragment Id="CM_G_Core">
3+
<FeatureRef Id="RunSunshineInstallScripts"/>
4+
</CPackWiXFragment>
5+
</CPackWiXPatch>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2+
<Fragment>
3+
<StandardDirectory Id="ProgramMenuFolder">
4+
<Directory Id="ProgramMenuSubfolder" Name="LizardByte">
5+
<Component Id="ApplicationShortcut" Guid="*">
6+
<Shortcut Id="ApplicationStartMenuShortcut"
7+
Name="Sunshine"
8+
Description="Sunshine Game Stream Host"
9+
Target="[INSTALL_ROOT]sunshine.exe"
10+
Arguments="--shortcut"
11+
WorkingDirectory="INSTALL_ROOT"/>
12+
<RemoveFolder Id="CleanUpShortCut" Directory="ProgramMenuSubfolder" On="uninstall"/>
13+
<RegistryValue Root="HKCU" Key="Software\LizardByte\Sunshine" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
14+
</Component>
15+
</Directory>
16+
</StandardDirectory>
17+
18+
<CustomAction Id="CA_ResetPermissions" Directory="INSTALL_ROOT" ExeCommand="&quot;[SystemFolder]icacls.exe&quot; &quot;.&quot; /reset" Execute="deferred" Return="ignore" Impersonate="no" />
19+
<CustomAction Id="CA_UpdatePathAdd" Directory="INSTALL_ROOT" ExeCommand="&quot;[SystemFolder]cmd.exe&quot; /c &quot;[INSTALL_ROOT]scripts\update-path.bat&quot; add" Execute="deferred" Return="ignore" Impersonate="no" />
20+
<CustomAction Id="CA_UpdatePathRemove" Directory="INSTALL_ROOT" ExeCommand="&quot;[SystemFolder]cmd.exe&quot; /c &quot;[INSTALL_ROOT]scripts\update-path.bat&quot; remove" Execute="deferred" Return="ignore" Impersonate="no" />
21+
<CustomAction Id="CA_MigrateConfig" Directory="INSTALL_ROOT" ExeCommand="&quot;[SystemFolder]cmd.exe&quot; /c &quot;[INSTALL_ROOT]scripts\migrate-config.bat&quot;" Execute="deferred" Return="ignore" Impersonate="no" />
22+
<CustomAction Id="CA_FirewallAdd" Directory="INSTALL_ROOT" ExeCommand="&quot;[SystemFolder]cmd.exe&quot; /c &quot;[INSTALL_ROOT]scripts\add-firewall-rule.bat&quot;" Execute="deferred" Return="ignore" Impersonate="no" />
23+
<CustomAction Id="CA_FirewallRemove" Directory="INSTALL_ROOT" ExeCommand="&quot;[SystemFolder]cmd.exe&quot; /c &quot;[INSTALL_ROOT]scripts\delete-firewall-rule.bat&quot;" Execute="deferred" Return="ignore" Impersonate="no" />
24+
<CustomAction Id="CA_GamepadInstall" Directory="INSTALL_ROOT" ExeCommand="&quot;[SystemFolder]WindowsPowerShell\v1.0\powershell.exe&quot; -NoProfile -ExecutionPolicy Bypass -File &quot;[INSTALL_ROOT]scripts\install-gamepad.ps1&quot;" Execute="deferred" Return="ignore" Impersonate="no" />
25+
<CustomAction Id="CA_GamepadUninstall" Directory="INSTALL_ROOT" ExeCommand="&quot;[SystemFolder]WindowsPowerShell\v1.0\powershell.exe&quot; -NoProfile -ExecutionPolicy Bypass -File &quot;[INSTALL_ROOT]scripts\uninstall-gamepad.ps1&quot;" Execute="deferred" Return="ignore" Impersonate="no" />
26+
<CustomAction Id="CA_ServiceInstall" Directory="INSTALL_ROOT" ExeCommand="&quot;[SystemFolder]cmd.exe&quot; /c &quot;[INSTALL_ROOT]scripts\install-service.bat&quot;" Execute="deferred" Return="ignore" Impersonate="no" />
27+
<CustomAction Id="CA_ServiceAutostart" Directory="INSTALL_ROOT" ExeCommand="&quot;[SystemFolder]cmd.exe&quot; /c &quot;[INSTALL_ROOT]scripts\autostart-service.bat&quot;" Execute="deferred" Return="ignore" Impersonate="no" />
28+
<CustomAction Id="CA_ServiceUninstall" Directory="INSTALL_ROOT" ExeCommand="&quot;[SystemFolder]cmd.exe&quot; /c &quot;[INSTALL_ROOT]scripts\uninstall-service.bat&quot;" Execute="deferred" Return="ignore" Impersonate="no" />
29+
<CustomAction Id="CA_RestoreNvPrefs" Directory="INSTALL_ROOT" ExeCommand="&quot;[INSTALL_ROOT]sunshine.exe&quot; --restore-nvprefs-undo" Execute="deferred" Return="ignore" Impersonate="no" />
30+
31+
<InstallExecuteSequence>
32+
<Custom Action="CA_ResetPermissions" After="InstallFiles" Condition="NOT Installed" />
33+
<Custom Action="CA_UpdatePathAdd" After="CA_ResetPermissions" Condition="NOT Installed" />
34+
<Custom Action="CA_MigrateConfig" After="CA_UpdatePathAdd" Condition="NOT Installed" />
35+
<Custom Action="CA_FirewallAdd" After="CA_MigrateConfig" Condition="NOT Installed" />
36+
<Custom Action="CA_GamepadInstall" After="CA_FirewallAdd" Condition="NOT Installed" />
37+
<Custom Action="CA_ServiceInstall" After="CA_GamepadInstall" Condition="NOT Installed" />
38+
<Custom Action="CA_ServiceAutostart" After="CA_ServiceInstall" Condition="NOT Installed" />
39+
40+
<Custom Action="CA_FirewallRemove" Before="RemoveFiles" Condition="REMOVE=&quot;ALL&quot;" />
41+
<Custom Action="CA_ServiceUninstall" Before="CA_FirewallRemove" Condition="REMOVE=&quot;ALL&quot;" />
42+
<Custom Action="CA_GamepadUninstall" After="CA_ServiceUninstall" Condition="REMOVE=&quot;ALL&quot;" />
43+
<Custom Action="CA_RestoreNvPrefs" After="CA_GamepadUninstall" Condition="REMOVE=&quot;ALL&quot;" />
44+
<Custom Action="CA_UpdatePathRemove" After="CA_RestoreNvPrefs" Condition="REMOVE=&quot;ALL&quot;" />
45+
</InstallExecuteSequence>
46+
47+
<!-- We need this in order to actually run our custom actions, but let's hide it -->
48+
<Feature Id="RunSunshineInstallScripts" Title="Run Sunshine Installation Scripts" Level="1" Display="hidden">
49+
<ComponentRef Id="ApplicationShortcut" />
50+
</Feature>
51+
</Fragment>
52+
</Wix>

0 commit comments

Comments
 (0)