Skip to content

Commit a748379

Browse files
authored
Update installer script to support UCRT and check for the versions of VS that support UCRT. (#745)
* Update installer script to support UCRT and check for the versions of VS that support UCRT. * Add option to install VS2019 Build Tools on 32-bit machines. The 2026 and 2019 install options are now disabled depending on whether or not the host machine is 64-bit. * Add accidentally removed label back in.
1 parent 15d388f commit a748379

3 files changed

Lines changed: 156 additions & 67 deletions

File tree

‎windows/d2-installer-descriptions.nsh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LangString DESC_Dmd2Files ${LANG_ENGLISH} "Digital Mars D version 2 compiler"
77
LangString DESC_SMShortcuts ${LANG_ENGLISH} "Add Shortcuts to the Start Menu to start the command interpreter with adjusted environment"
88
LangString DESC_AddD2ToPath ${LANG_ENGLISH} "Modify the PATH environment variable so DMD can be used from any command prompt"
99

10-
LangString DESC_VisualDDownload ${LANG_ENGLISH} "Visual Studio package providing both project management and language services. It works with Visual Studio 2008-2017 (and the free VS Shells)"
10+
LangString DESC_VisualDDownload ${LANG_ENGLISH} "Visual Studio package providing both project management and language services."
1111

1212

1313
; Shortcuts

‎windows/d2-installer.nsi‎

Lines changed: 141 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,34 @@
4545
; --------------------
4646
; Files
4747
!define VisualDFilename "VisualD-v${VersionVisualD}.exe"
48-
!define VS2013Filename "vs_community2013.exe"
49-
!define VS2017Filename "vs_community2017.exe"
50-
!define VS2017BTFilename "vs_BuildTools2017.exe"
51-
!define VS2019Filename "vs_community2019.exe"
48+
!define VS2026Filename "vs_community2026.exe"
49+
!define VS2026BTFilename "vs_BuildTools2026.exe"
5250
!define VS2019BTFilename "vs_BuildTools2019.exe"
53-
!define VCRedistx86Filename "vcredist_x86.exe"
54-
!define VCRedistx64Filename "vcredist_x64.exe"
51+
!define VCRedistx86Filename "vc_redist.x86.exe"
52+
!define VCRedistx64Filename "vc_redist.x64.exe"
5553

5654
; URLs
5755
!define VisualDBaseURL "https://github.com/dlang/visuald/releases/download"
5856

5957
!define VisualDUrl "${VisualDBaseURL}/v${VersionVisualD}/${VisualDFilename}"
6058

61-
!define VS2013Url "http://go.microsoft.com/fwlink/?LinkId=517284"
62-
!define VS2017Url "https://download.visualstudio.microsoft.com/download/pr/100404311/045b56eb413191d03850ecc425172a7d/vs_Community.exe"
63-
!define VS2017BuildToolsUrl "https://download.visualstudio.microsoft.com/download/pr/100404314/e64d79b40219aea618ce2fe10ebd5f0d/vs_BuildTools.exe"
64-
!define VS2019Url "https://download.visualstudio.microsoft.com/download/pr/8ab6eab3-e151-4f4d-9ca5-07f8434e46bb/8cc1a4ebd138b5d0c2b97501a198f5eacdc434daa8a5c6564c8e23fdaaad3619/vs_Community.exe"
65-
!define VS2019BuildToolsUrl "https://download.visualstudio.microsoft.com/download/pr/8ab6eab3-e151-4f4d-9ca5-07f8434e46bb/cfffd18469d936d6cb9dff55fd4ae538035e7f247f1756c5a31f3e03751d7ee7/vs_BuildTools.exe"
59+
!define VS2026Url "https://aka.ms/vs/stable/vs_community.exe"
60+
!define VS2026BuildToolsUrl "https://aka.ms/vs/stable/vs_buildtools.exe"
6661

67-
; see https://stackoverflow.com/questions/12206314/detect-if-visual-c-redistributable-for-visual-studio-2012-is-installed/14878248
68-
; selecting VC2010
69-
!define VCRedistx86Url "https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x86.exe"
70-
!define VCRedistx64Url "https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x64.exe"
62+
; VS 2019 (channel 16) is the last release that installs on 32-bit Windows, since
63+
; VS 2022 and later require a 64-bit host. Its Build Tools are offered for 32-bit
64+
; machines. This evergreen permalink resolves to the latest 16.x servicing build.
65+
!define VS2019BuildToolsUrl "https://aka.ms/vs/16/release/vs_buildtools.exe"
7166

72-
!define VCRedistx86RegKey "SOFTWARE\Classes\Installer\Products\1926E8D15D0BCE53481466615F760A7F"
73-
!define VCRedistx64RegKey "SOFTWARE\Classes\Installer\Products\1D5E3C0FEDA1E123187686FED06E995A"
67+
; Latest supported Visual C++ v14 Redistributable, shared by VS 2017-2026 and
68+
; containing the Universal C Runtime (UCRT). The aka.ms links redirect to the
69+
; current package; inetc::get follows HTTP redirects, so the permalinks are fine.
70+
!define VCRedistx86Url "https://aka.ms/vc14/vc_redist.x86.exe"
71+
!define VCRedistx64Url "https://aka.ms/vc14/vc_redist.x64.exe"
72+
73+
; Registry keys written by the installed VC++ v14 Redistributable runtimes
74+
!define VCRedistx86RegKey "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\X86"
75+
!define VCRedistx64RegKey "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\X64"
7476

7577
; ----------------
7678
; Publishing Details
@@ -255,6 +257,8 @@ SectionGroup /e "D2"
255257
FileOpen $0 "$INSTDIR\dmd2vars32.bat" w
256258
FileWrite $0 "@echo.$\n"
257259
FileWrite $0 "@echo Setting up 32-bit environment for using DMD 2 from %~dp0dmd2\windows\bin.$\n"
260+
FileWrite $0 "@echo.$\n"
261+
FileWrite $0 "@echo Generated programs link against the Universal C Runtime (UCRT) included with Windows.$\n"
258262
FileWrite $0 "@set PATH=%~dp0dmd2\windows\bin;%PATH%$\n"
259263
FileClose $0
260264

@@ -264,6 +268,7 @@ SectionGroup /e "D2"
264268
FileWrite $0 "@echo Setting up 64-bit environment for using DMD 2 from %~dp0dmd2\windows\bin.$\n"
265269
FileWrite $0 "@echo.$\n"
266270
FileWrite $0 "@echo dmd must still be called with -m64 in order to generate 64-bit code.$\n"
271+
FileWrite $0 "@echo Generated programs link against the Universal C Runtime (UCRT) included with Windows.$\n"
267272
FileWrite $0 "@echo This command prompt adds the path of extra 64-bit DLLs so generated programs$\n"
268273
FileWrite $0 "@echo which use the extra DLLs (notably libcurl) can be executed.$\n"
269274
FileWrite $0 "@set PATH=%~dp0dmd2\windows\bin;%PATH%$\n"
@@ -321,37 +326,52 @@ Function VCInstallPage
321326
Abort
322327
ask_vs:
323328

324-
!insertmacro MUI_HEADER_TEXT "Choose Visual Studio Installation" "Choose the Visual C runtime to link against"
329+
!insertmacro MUI_HEADER_TEXT "Install Microsoft C/C++ Build Tools" "Install the build tools required to compile and link D programs"
325330
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "vcinstall.ini"
331+
332+
${If} ${RunningX64}
333+
; The VS 2019 Build Tools option (Field 4) only makes sense on 32-bit Windows,
334+
; since VS 2022 and later require a 64-bit host. Disable it on 64-bit systems.
335+
!insertmacro MUI_INSTALLOPTIONS_WRITE "vcinstall.ini" "Field 4" "Flags" "DISABLED"
336+
${Else}
337+
; VS 2022 and later require a 64-bit host, so the VS 2026 options (Fields 2 and 3)
338+
; cannot be installed on 32-bit Windows. Gray them out and make the VS 2019 Build
339+
; Tools the default selection instead.
340+
!insertmacro MUI_INSTALLOPTIONS_WRITE "vcinstall.ini" "Field 2" "Flags" "DISABLED"
341+
!insertmacro MUI_INSTALLOPTIONS_WRITE "vcinstall.ini" "Field 3" "State" "0"
342+
!insertmacro MUI_INSTALLOPTIONS_WRITE "vcinstall.ini" "Field 3" "Flags" "DISABLED"
343+
!insertmacro MUI_INSTALLOPTIONS_WRITE "vcinstall.ini" "Field 4" "State" "1"
344+
${EndIf}
345+
326346
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "vcinstall.ini"
327347

328348
FunctionEnd
329349

330350
Function VCInstallPageValidate
331351

332352
!insertmacro MUI_INSTALLOPTIONS_READ $0 "vcinstall.ini" "Field 2" "State"
333-
StrCmp $0 1 install_vs2013
353+
StrCmp $0 1 install_vs2026
334354
!insertmacro MUI_INSTALLOPTIONS_READ $0 "vcinstall.ini" "Field 3" "State"
335-
StrCmp $0 1 install_vs2019
355+
StrCmp $0 1 install_bt2026
336356
!insertmacro MUI_INSTALLOPTIONS_READ $0 "vcinstall.ini" "Field 4" "State"
337357
StrCmp $0 1 install_bt2019
338358
!insertmacro MUI_INSTALLOPTIONS_READ $0 "vcinstall.ini" "Field 5" "State"
339-
StrCmp $0 1 install_vc2010
359+
StrCmp $0 1 install_vcredist
340360
goto done_vc
341361

342-
install_vs2013:
343-
!insertmacro DownloadAndRun ${VS2013Filename} ${VS2013Url} ""
362+
install_vs2026:
363+
!insertmacro DownloadAndRun ${VS2026Filename} ${VS2026Url} ""
344364
goto done_vc
345365

346-
install_vs2019:
347-
!insertmacro DownloadAndRun ${VS2019Filename} ${VS2019Url} ""
366+
install_bt2026:
367+
!insertmacro DownloadAndRun ${VS2026BTFilename} ${VS2026BuildToolsUrl} ""
348368
goto done_vc
349369

350370
install_bt2019:
351371
!insertmacro DownloadAndRun ${VS2019BTFilename} ${VS2019BuildToolsUrl} ""
352372
goto done_vc
353373

354-
install_vc2010:
374+
install_vcredist:
355375
Call InstallVCRedistributable
356376
goto done_vc
357377

@@ -365,19 +385,23 @@ FunctionEnd
365385

366386
Function InstallVCRedistributable
367387

368-
SetRegView 64 ; look at the 64-bit registry hive if available
388+
; The x86 runtime registers under the 32-bit registry view
389+
SetRegView 32
369390
ClearErrors
370-
ReadRegStr $0 HKLM "${VCRedistx86RegKey}" "ProductName"
371-
IfErrors 0 vcredistx86_installed
391+
ReadRegDWORD $0 HKLM "${VCRedistx86RegKey}" "Installed"
392+
${If} $0 != 1
372393
!insertmacro DownloadAndRun ${VCRedistx86Filename} ${VCRedistx86Url} ""
373-
vcredistx86_installed:
394+
${EndIf}
374395

396+
; The x64 runtime registers under the 64-bit registry view
397+
SetRegView 64
375398
ClearErrors
376-
ReadRegStr $0 HKLM "${VCRedistx64RegKey}" "ProductName"
377-
IfErrors 0 vcredistx64_installed
399+
ReadRegDWORD $0 HKLM "${VCRedistx64RegKey}" "Installed"
400+
${If} $0 != 1
378401
!insertmacro DownloadAndRun ${VCRedistx64Filename} ${VCRedistx64Url} ""
379-
vcredistx64_installed:
380-
SetRegView 32 ; retore default
402+
${EndIf}
403+
404+
SetRegView 32 ; restore default
381405

382406
FunctionEnd
383407

@@ -397,6 +421,26 @@ Function DetectVC
397421
Goto done
398422
no_vswhere:
399423

424+
Call DetectVS2026_InstallationFolder
425+
StrCpy $1 "VC2026"
426+
StrCmp $0 "" not_vc2026 vs2026
427+
vs2026:
428+
${LineRead} "$0\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt" "1" $2
429+
IfErrors not_vc2026
430+
StrCpy $0 "$0\VC\Tools\MSVC\$2"
431+
Goto done_vs
432+
not_vc2026:
433+
434+
Call DetectVS2022_InstallationFolder
435+
StrCpy $1 "VC2022"
436+
StrCmp $0 "" not_vc2022 vs2022
437+
vs2022:
438+
${LineRead} "$0\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt" "1" $2
439+
IfErrors not_vc2022
440+
StrCpy $0 "$0\VC\Tools\MSVC\$2"
441+
Goto done_vs
442+
not_vc2022:
443+
400444
Call DetectVS2019_InstallationFolder
401445
StrCpy $1 "VC2019"
402446
StrCmp $0 "" not_vc2019 vs2019
@@ -440,22 +484,8 @@ Function DetectVC
440484
ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\14.0\Setup\VC" "ProductDir"
441485
StrCpy $1 "VC2015"
442486
IfErrors 0 done_vs
443-
ClearErrors
444-
ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\12.0\Setup\VC" "ProductDir"
445-
StrCpy $1 "VC2013"
446-
IfErrors 0 done_vs
447-
ClearErrors
448-
ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\11.0\Setup\VC" "ProductDir"
449-
StrCpy $1 "VC2012"
450-
IfErrors 0 done_vs
451-
ClearErrors
452-
ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\10.0\Setup\VC" "ProductDir"
453-
StrCpy $1 "VC2010"
454-
IfErrors 0 done_vs
455-
ClearErrors
456-
ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\9.0\Setup\VC" "ProductDir"
457-
StrCpy $1 "VC2008"
458-
IfErrors done done_vs
487+
488+
Goto done
459489

460490
done_vs:
461491
StrCpy $VCPath $0
@@ -597,7 +627,7 @@ Function un.onInit
597627
FunctionEnd
598628

599629
;--------------------------------------------------------
600-
; VS 2017/2019 detection functions
630+
; VS 2017/2019/2022/2026 detection functions
601631
;
602632
; returns path to VS (not VC) in $0
603633
;--------------------------------------------------------
@@ -613,7 +643,6 @@ Function DetectVS2017BuildTools_InstallationFolder
613643
StrCmp $2 "Visual Studio Build Tools 2017" 0 NotVS2017BT
614644
ReadRegStr $2 HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1 InstallLocation
615645
IfErrors NoInstallLocation
616-
; MessageBox MB_YESNO|MB_ICONQUESTION "$2$\n$\nMore?" IDYES 0 IDNO done
617646
StrCpy $0 "$2\\"
618647
return
619648
NoInstallLocation:
@@ -626,6 +655,66 @@ Function DetectVS2017BuildTools_InstallationFolder
626655

627656
FunctionEnd
628657

658+
Function DetectVS2026_InstallationFolder
659+
660+
ClearErrors
661+
StrCpy $0 0
662+
loop:
663+
EnumRegKey $1 HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall $0
664+
StrCmp $1 "" done
665+
ReadRegStr $2 HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1 DisplayName
666+
IfErrors NoDisplayName
667+
StrCpy $3 $2 14
668+
StrCmp $3 "Visual Studio " 0 NotVS2026
669+
StrCpy $3 $2 12 -12
670+
StrCmp $3 "2026 Preview" IsVS2026
671+
StrCpy $3 $2 4 -4
672+
StrCmp $3 "2026" IsVS2026 NotVS2026
673+
IsVS2026:
674+
ReadRegStr $2 HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1 InstallLocation
675+
IfErrors NoInstallLocation
676+
StrCpy $0 "$2\\"
677+
return
678+
NoInstallLocation:
679+
NotVS2026:
680+
NoDisplayName:
681+
IntOp $0 $0 + 1
682+
Goto loop
683+
done:
684+
StrCpy $0 ""
685+
686+
FunctionEnd
687+
688+
Function DetectVS2022_InstallationFolder
689+
690+
ClearErrors
691+
StrCpy $0 0
692+
loop:
693+
EnumRegKey $1 HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall $0
694+
StrCmp $1 "" done
695+
ReadRegStr $2 HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1 DisplayName
696+
IfErrors NoDisplayName
697+
StrCpy $3 $2 14
698+
StrCmp $3 "Visual Studio " 0 NotVS2022
699+
StrCpy $3 $2 12 -12
700+
StrCmp $3 "2022 Preview" IsVS2022
701+
StrCpy $3 $2 4 -4
702+
StrCmp $3 "2022" IsVS2022 NotVS2022
703+
IsVS2022:
704+
ReadRegStr $2 HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1 InstallLocation
705+
IfErrors NoInstallLocation
706+
StrCpy $0 "$2\\"
707+
return
708+
NoInstallLocation:
709+
NotVS2022:
710+
NoDisplayName:
711+
IntOp $0 $0 + 1
712+
Goto loop
713+
done:
714+
StrCpy $0 ""
715+
716+
FunctionEnd
717+
629718
Function DetectVS2019_InstallationFolder
630719

631720
ClearErrors

‎windows/vcinstall.ini‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,52 @@ Bottom=136
1212

1313
[Field 2]
1414
Type=RadioButton
15-
Text=Download and install Visual Studio 2013
15+
Text=Download and install Visual Studio 2026
1616
State=0
1717
Left=20
1818
Right=300
1919
Top=48
20-
Bottom=60
20+
Bottom=62
2121

2222
[Field 3]
2323
Type=RadioButton
24-
Text=Download and install Visual Studio 2019
24+
Text=Download and install Build Tools for Visual Studio 2026
2525
State=1
2626
Left=20
2727
Right=300
28-
Top=64
29-
Bottom=76
28+
Top=66
29+
Bottom=80
3030

3131
[Field 4]
3232
Type=RadioButton
33-
Text=Download and install Build Tools for Visual Studio 2019
33+
Text=Download and install Build Tools for Visual Studio 2019 (required for 32-bit machines)
3434
State=0
3535
Left=20
3636
Right=300
37-
Top=80
38-
Bottom=94
37+
Top=84
38+
Bottom=98
3939

4040
[Field 5]
4141
Type=RadioButton
42-
Text=Install VC2010 redistributables to use it with MinGW Platform libraries
42+
Text=Install the Universal C Runtime (UCRT) redistributables to use DMD with the MinGW Platform libraries
4343
State=0
4444
Left=20
4545
Right=300
46-
Top=98
47-
Bottom=112
46+
Top=102
47+
Bottom=116
4848

4949
[Field 6]
5050
Type=RadioButton
5151
Text=Do nothing (you can manually install any of the options above later)
5252
State=0
5353
Left=20
5454
Right=300
55-
Top=116
56-
Bottom=130
55+
Top=120
56+
Bottom=134
5757

5858
[Field 7]
5959
Type=Label
60-
Text=No Visual Studio Installation was found on your system. To build 64-bit programs or 32-bit programs targeting the VC runtime, you need to install one of the options below.
60+
Text=No Microsoft C/C++ build tools were found on your system. They are needed to compile and link programs against the Universal C Runtime (UCRT). Be sure to select the "Desktop Development with C++" workload during installation.
6161
Left=0
6262
Right=300
6363
Top=0

0 commit comments

Comments
 (0)