diff --git a/packages/desktop/src-tauri/resources/vc_redist.x64.exe b/packages/desktop/src-tauri/resources/vc_redist.x64.exe new file mode 100644 index 0000000000..ef26bb5af2 Binary files /dev/null and b/packages/desktop/src-tauri/resources/vc_redist.x64.exe differ diff --git a/packages/desktop/src-tauri/tauri.conf.json b/packages/desktop/src-tauri/tauri.conf.json index d5ca15b8a7..b02c9441f1 100644 --- a/packages/desktop/src-tauri/tauri.conf.json +++ b/packages/desktop/src-tauri/tauri.conf.json @@ -34,6 +34,7 @@ "active": true, "targets": ["deb", "rpm", "dmg", "nsis", "app"], "externalBin": ["sidecars/opencode-cli"], + "resources": ["resources/vc_redist.x64.exe"], "linux": { "rpm": { "compression": { @@ -48,7 +49,8 @@ "nsis": { "installerIcon": "icons/dev/icon.ico", "headerImage": "assets/nsis-header.bmp", - "sidebarImage": "assets/nsis-sidebar.bmp" + "sidebarImage": "assets/nsis-sidebar.bmp", + "installerHooks": "./windows/hooks.nsh" } } }, diff --git a/packages/desktop/src-tauri/tauri.prod.conf.json b/packages/desktop/src-tauri/tauri.prod.conf.json index 0416c59cbb..e478cf50cf 100644 --- a/packages/desktop/src-tauri/tauri.prod.conf.json +++ b/packages/desktop/src-tauri/tauri.prod.conf.json @@ -11,9 +11,11 @@ "icons/prod/icon.icns", "icons/prod/icon.ico" ], + "resources": ["resources/vc_redist.x64.exe"], "windows": { "nsis": { - "installerIcon": "icons/prod/icon.ico" + "installerIcon": "icons/prod/icon.ico", + "installerHooks": "./windows/hooks.nsh" } }, "linux": { diff --git a/packages/desktop/src-tauri/windows/hooks.nsh b/packages/desktop/src-tauri/windows/hooks.nsh new file mode 100644 index 0000000000..6890a6ae0e --- /dev/null +++ b/packages/desktop/src-tauri/windows/hooks.nsh @@ -0,0 +1,24 @@ +!include "FileFunc.nsh" + +!macro NSIS_HOOK_POSTINSTALL + ReadRegDWord $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed" + ${If} $0 == 1 + DetailPrint "Visual C++ Redistributable already installed" + Goto vcredist_done + ${EndIf} + + ${If} ${FileExists} "$INSTDIR\resources\vc_redist.x64.exe" + DetailPrint "Installing Visual C++ Redistributable..." + CopyFiles "$INSTDIR\resources\vc_redist.x64.exe" "$TEMP\vc_redist.x64.exe" + ExecWait '"$TEMP\vc_redist.x64.exe" /install /quiet /norestart' $0 + ${If} $0 == 0 + DetailPrint "Visual C++ Redistributable installed successfully" + ${Else} + MessageBox MB_ICONEXCLAMATION "Visual C++ installation failed. Some features may not work." + ${EndIf} + Delete "$TEMP\vc_redist.x64.exe" + Delete "$INSTDIR\resources\vc_redist.x64.exe" + ${EndIf} + + vcredist_done: +!macroend