Merge pull request #2865 from Ryex/nsis_vc_redist

add vc_redist as a NSIS install section
This commit is contained in:
Alexandru Ionut Tripon 2024-10-08 14:09:22 +03:00 committed by GitHub
commit dc1f56e108
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 69 additions and 3 deletions

View File

@ -84,6 +84,8 @@ jobs:
qt_arch: ""
qt_version: "6.7.2"
qt_modules: "qt5compat qtimageformats qtnetworkauth"
nscurl_tag: "v24.9.26.122"
nscurl_sha256: "AEE6C4BE3CB6455858E9C1EE4B3AFE0DB9960FA03FE99CCDEDC28390D57CCBB0"
- os: windows-2022
name: "Windows-MSVC-arm64"
@ -95,6 +97,8 @@ jobs:
qt_arch: "win64_msvc2019_arm64"
qt_version: "6.7.2"
qt_modules: "qt5compat qtimageformats qtnetworkauth"
nscurl_tag: "v24.9.26.122"
nscurl_sha256: "AEE6C4BE3CB6455858E9C1EE4B3AFE0DB9960FA03FE99CCDEDC28390D57CCBB0"
- os: macos-14
name: macOS
@ -474,6 +478,16 @@ jobs:
- name: Package (Windows, installer)
if: runner.os == 'Windows'
run: |
if ('${{ matrix.nscurl_tag }}') {
New-Item -Name NSISPlugins -ItemType Directory
Invoke-Webrequest https://github.com/negrutiu/nsis-nscurl/releases/download/${{ matrix.nscurl_tag }}/NScurl.zip -OutFile NSISPlugins\NScurl.zip
$nscurl_hash = Get-FileHash NSISPlugins\NScurl.zip -Algorithm Sha256 | Select-Object -ExpandProperty Hash
if ( $nscurl_hash -ne "${{ matrix.nscurl_sha256 }}") {
echo "::error:: NSCurl.zip sha256 mismatch"
exit 1
}
Expand-Archive -Path NSISPlugins\NScurl.zip -DestinationPath NSISPlugins\NScurl
}
cd ${{ env.INSTALL_DIR }}
makensis -NOCD "${{ github.workspace }}/${{ env.BUILD_DIR }}/program_info/win_install.nsi"

View File

@ -41,6 +41,31 @@ configure_file(org.prismlauncher.PrismLauncher.metainfo.xml.in org.prismlauncher
configure_file(prismlauncher.rc.in prismlauncher.rc @ONLY)
configure_file(prismlauncher.manifest.in prismlauncher.manifest @ONLY)
configure_file(prismlauncher.ico prismlauncher.ico COPYONLY)
if(MSVC)
set(Launcher_MSVC_Redist_NSIS_Section [=[
!ifdef haveNScurl
Section "Visual Studio Runtime"
Var /GLOBAL vc_redist_exe
${If} ${IsNativeARM64}
StrCpy $vc_redist_exe "vc_redist.arm64.exe"
${Else}
StrCpy $vc_redist_exe "vc_redist.x64.exe"
${EndIf}
DetailPrint 'Downloading Microsoft Visual C++ Redistributable...'
NScurl::http GET "https://aka.ms/vs/17/release/$vc_redist_exe" "$INSTDIR\vc_redist\$vc_redist_exe" /INSIST /CANCEL /Zone.Identifier /END
Pop $0
${If} $0 == "OK"
DetailPrint "Download successful"
ExecWait "$INSTDIR\vc_redist\$vc_redist_exe /install /passive /norestart\"
${Else}
DetailPrint "Download failed with error $0"
${EndIf}
SectionEnd
!endif
]=])
endif()
configure_file(win_install.nsi.in win_install.nsi @ONLY)
if(SCDOC_FOUND)

View File

@ -2,6 +2,8 @@
!include "LogicLib.nsh"
!include "MUI2.nsh"
!include "x64.nsh"
Unicode true
Name "@Launcher_DisplayName@"
@ -112,6 +114,16 @@ VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "@Launcher_Copyright@"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "@Launcher_VERSION_NAME4@"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "@Launcher_VERSION_NAME4@"
;--------------------------------
; Conditional comp with file exist
!macro CompileTimeIfFileExist path define
!tempfile tmpinc
!system 'IF EXIST "${path}" echo !define ${define} > "${tmpinc}"'
!include "${tmpinc}"
!delfile "${tmpinc}"
!undef tmpinc
!macroend
;--------------------------------
; Shell Associate Macros
@ -175,7 +187,7 @@ VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "@Launcher_VERSION_NAME4@
!macroend
!macro APP_UNASSOCIATE EXT APP_ID
!macro APP_UNASSOCIATE EXT APP_ID APP_EXE
# Unregister file type
ClearErrors
@ -336,6 +348,19 @@ Section "" UninstallPrevious
SectionEnd
;------------------------------------
; include nice plugins
; NScurl - curl in NSIS
; used for MSVS redist download
; extract to ../NSISPlugins/NScurl
; https://github.com/negrutiu/nsis-nscurl/releases/latest/download/NScurl.zip
!insertmacro CompileTimeIfFileExist "../NSISPlugins/NScurl/Plugins/" haveNScurl
!ifdef haveNScurl
!AddPluginDir /x86-unicode "../NSISPlugins/NScurl/Plugins/x86-unicode"
!AddPluginDir /x86-ansi "../NSISPlugins/NScurl/Plugins/x86-ansi"
!AddPluginDir /amd64-unicode "../NSISPlugins/NScurl/Plugins/amd64-unicode"
!endif
;------------------------------------
@ -396,6 +421,8 @@ Section "@Launcher_DisplayName@"
SectionEnd
@Launcher_MSVC_Redist_NSIS_Section@
Section "Start Menu Shortcut" SM_SHORTCUTS
CreateShortcut "$SMPROGRAMS\@Launcher_DisplayName@.lnk" "$INSTDIR\@Launcher_APP_BINARY_NAME@.exe" "" "$INSTDIR\@Launcher_APP_BINARY_NAME@.exe" 0
@ -464,8 +491,8 @@ Section -un.ShellAssoc
!insertmacro APP_TEARDOWN_DEFAULT `${APPID}` `${APPNAME}` `${APPEXE}`
!insertmacro APP_UNASSOCIATE ".zip" `${APPID}`
!insertmacro APP_UNASSOCIATE ".mrpack" `${APPID}`
!insertmacro APP_UNASSOCIATE ".zip" `${APPID}` `${APPEXE}`
!insertmacro APP_UNASSOCIATE ".mrpack" `${APPID}` `${APPEXE}`
!insertmacro NotifyShell_AssocChanged
SectionEnd