chore: update hooks to install vcredist.exe and update path for dll and license file

This commit is contained in:
Minh141120 2025-09-23 13:01:09 +07:00
parent 7257eb4ae6
commit 50b66eff74
2 changed files with 59 additions and 24 deletions

View File

@ -1,8 +1,8 @@
{ {
"bundle": { "bundle": {
"targets": ["nsis"], "targets": ["nsis"],
"resources": ["resources/pre-install/**/*"], "resources": ["resources/pre-install/**/*", "resources/lib/vulkan-1.dll", "resources/LICENSE"],
"externalBin": ["resources/bin/bun", "resources/bin/uv", "resources/lib/vulkan-1.dll", "resources/LICENSE"], "externalBin": ["resources/bin/bun", "resources/bin/uv"],
"windows": { "windows": {
"nsis": { "nsis": {
"installerHooks": "./windows/hooks.nsh", "installerHooks": "./windows/hooks.nsh",

View File

@ -1,30 +1,65 @@
!macro NSIS_HOOK_POSTINSTALL !macro NSIS_HOOK_POSTINSTALL
; Check if Visual C++ 2019 Redistributable is installed (via Windows Registry) ; Check if Visual C++ Redistributable is already installed
ReadRegDWord $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed" ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Version"
${If} $0 == ""
${If} $0 == 1 ; Try alternative registry location
DetailPrint "Visual C++ Redistributable already installed" ReadRegStr $0 HKLM "SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Version"
Goto vcredist_done
${EndIf} ${EndIf}
; Install from bundled MSI if not installed ${If} $0 == ""
${If} ${FileExists} "$INSTDIR\resources\vc_redist.x64.msi" ; VC++ Redistributable not found, need to install
DetailPrint "Installing Visual C++ Redistributable..." DetailPrint "Visual C++ Redistributable not found, downloading and installing..."
; Copy to TEMP folder and then execute installer
CopyFiles "$INSTDIR\resources\vc_redist.x64.msi" "$TEMP\vc_redist.x64.msi" ; Download VC++ Redistributable
ExecWait 'msiexec /i "$TEMP\vc_redist.x64.msi" /passive /norestart' $0 Delete "$TEMP\vc_redist.x64.exe"
DetailPrint "Downloading Visual C++ Redistributable..."
; Check wether installation process exited successfully (code 0) or not NSISdl::download "https://aka.ms/vs/17/release/vc_redist.x64.exe" "$TEMP\vc_redist.x64.exe"
${If} $0 == 0 Pop $1
DetailPrint "Visual C++ Redistributable installed successfully"
${If} $1 == "success"
DetailPrint "Visual C++ Redistributable download successful"
; Install VC++ Redistributable silently
DetailPrint "Installing Visual C++ Redistributable..."
ExecWait '"$TEMP\vc_redist.x64.exe" /quiet /norestart' $2
${If} $2 == 0
DetailPrint "Visual C++ Redistributable installed successfully"
${ElseIf} $2 == 1638
DetailPrint "Visual C++ Redistributable already installed (newer version)"
${ElseIf} $2 == 3010
DetailPrint "Visual C++ Redistributable installed successfully (restart required)"
${Else}
DetailPrint "Visual C++ installation failed with exit code: $2"
MessageBox MB_ICONEXCLAMATION "Visual C++ installation failed. Some features may not work."
${EndIf}
; Clean up downloaded file
Delete "$TEMP\vc_redist.x64.exe"
${Else} ${Else}
MessageBox MB_ICONEXCLAMATION "Visual C++ installation failed. Some features may not work." DetailPrint "Failed to download Visual C++ Redistributable: $1"
MessageBox MB_ICONEXCLAMATION "Failed to download Visual C++ Redistributable. Some features may not work."
${EndIf} ${EndIf}
${Else}
; Clean up setup files from TEMP and your installed app DetailPrint "Visual C++ Redistributable already installed (version: $0)"
Delete "$TEMP\vc_redist.x64.msi"
Delete "$INSTDIR\resources\vc_redist.x64.msi"
${EndIf} ${EndIf}
vcredist_done: ; ---- Copy LICENSE to install root ----
${If} ${FileExists} "$INSTDIR\resources\LICENSE"
CopyFiles /SILENT "$INSTDIR\resources\LICENSE" "$INSTDIR\LICENSE"
DetailPrint "Copied LICENSE to install root"
${EndIf}
; ---- Copy vulkan-1.dll to install root ----
${If} ${FileExists} "$INSTDIR\resources\lib\vulkan-1.dll"
CopyFiles /SILENT "$INSTDIR\resources\lib\vulkan-1.dll" "$INSTDIR\vulkan-1.dll"
DetailPrint "Copied vulkan-1.dll to install root"
; Optional cleanup - remove from resources folder
Delete "$INSTDIR\resources\lib\vulkan-1.dll"
; Only remove the lib directory if it's empty
RMDir "$INSTDIR\resources\lib"
${Else}
DetailPrint "vulkan-1.dll not found at expected location: $INSTDIR\resources\lib\vulkan-1.dll"
${EndIf}
!macroend !macroend