Skip to content

Commit 40cebf9

Browse files
committed
installer: support local and Ci vcredist files by using a compile time if
1 parent 17d30b8 commit 40cebf9

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

tools/installer/setup.nsi

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ SectionEnd
191191
;; source: partially https://stackoverflow.com/questions/62092185/how-to-install-the-visual-c-redist-using-nsis
192192
;; and https://gist.github.com/mattiasghodsian/a30f50568792939e35e93e6bc2084c2a
193193

194-
!define VC_REDITS_NAME "vc_redist.x64.exe"
194+
!define VC_REDIST_NAME "vc_redist.x64.exe"
195195

196196
Section "-hidden Visual Studio C++ Runtime"
197197
; install the MSVC C++ Redistributable (Runtime libraries needed by C++ and C), only if not already installed
@@ -204,12 +204,26 @@ Section "-hidden Visual Studio C++ Runtime"
204204
DetailPrint "Visual Studio C++ Runtime NOT installed, launching installer"
205205

206206
SetOutPath "$INSTDIR"
207-
; 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}"
208-
File "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Redist\MSVC\v143\${VC_REDITS_NAME}"
207+
208+
; this is executed at compile time, so we ge the correct path of the file, if we are in teh CI or local it differs
209+
!if "$%CI%" == "true"
210+
; this dir is specific to github runners
211+
!define VC_REDIST_ROOT "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Redist\MSVC"
212+
!define VC_REDIST_VERSION "v143"
213+
!else
214+
; TODO: allow custom folders via env variable
215+
; this dir is specific to my local setup
216+
!define VC_REDIST_ROOT "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC"
217+
!define VC_REDIST_VERSION "v143"
218+
!endif
219+
220+
File "${VC_REDIST_ROOT}\${VC_REDIST_VERSION}\${VC_REDIST_NAME}"
221+
209222
; error code is ignored, that is intended
210-
ExecWait '"$INSTDIR\${VC_REDITS_NAME}" /install'
223+
ExecWait '"$INSTDIR\${VC_REDIST_NAME}" /install'
224+
211225
; it is not needed anymore
212-
Delete "$INSTDIR\${VC_REDITS_NAME}"
226+
Delete "$INSTDIR\${VC_REDIST_NAME}"
213227
${Else}
214228
DetailPrint "Visual Studio C++ Runtime already installed, skipping installing it"
215229
${EndIf}

0 commit comments

Comments
 (0)