Skip to content

Commit d03bfa7

Browse files
committed
windows installer:
- also install the c++ Redist. Runtime Libraries
1 parent 1e292ed commit d03bfa7

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tools/installer/setup.nsi

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,35 @@ Section "Core App" CoreApp
162162
WriteRegDWORD HKCU "${ARP}" "NoRepair" 1
163163
SectionEnd
164164

165+
;--------------------------------
166+
; Section - Install C++ Redist., always installed, if needed, hidden
167+
;; source: partially https://stackoverflow.com/questions/62092185/how-to-install-the-visual-c-redist-using-nsis
168+
;; and https://gist.github.com/mattiasghodsian/a30f50568792939e35e93e6bc2084c2a
169+
170+
!define VC_REDITS_NAME "vc_redist.x64.exe"
171+
172+
Section "-hidden Visual Studio C++ Runtime"
173+
; install the MSVC C++ Redistributable (Runtime libraries needed by C++ and C), only if not already installed
174+
ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
175+
176+
; if it isn't preseent it will be 0, otherwise it will be 0 or 1, depending if this is installed or not
177+
${If} $0 == 0
178+
; we have the C++ redist. not installed
179+
180+
DetailPrint "Visual Studio C++ Runtime NOT installed, launching installer"
181+
182+
SetOutPath "$INSTDIR"
183+
; this dir is specifiy to github runners, locally it would be: "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\v143\${VC_REDITS_NAME}"
184+
File "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Redist\MSVC\v143\${VC_REDITS_NAME}"
185+
; error code is ignored, that is intended
186+
ExecWait '"$INSTDIR\${VC_REDITS_NAME}" /install'
187+
; it is not needed anymore
188+
Delete "$INSTDIR\${VC_REDITS_NAME}"
189+
${Else}
190+
DetailPrint "Visual Studio C++ Runtime already installed, skipping installing it"
191+
${EndIf}
192+
SectionEnd
193+
165194

166195
;--------------------------------
167196
; Section - Install Music assets, optional, can be selected by user if he wants to have music

0 commit comments

Comments
 (0)