Skip to content

Commit c64ced1

Browse files
committed
Update VS installation instructions
1 parent 9a1bebc commit c64ced1

File tree

4 files changed

+39
-18
lines changed

4 files changed

+39
-18
lines changed

src-opam/Install.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ if "%ERRORLEVEL%"=="3010" (
1212
exit /b !ERR!
1313
)
1414
)
15+
16+
exit /b 0

src-opam/opam.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ let windows_msvc_opam2 ?win10_revision ?winget ?(labels = []) ~opam_hashes
476476
Windows.install_visual_studio_build_tools
477477
[
478478
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64";
479+
(* Without 18362, rc.exe is missing from the Path. *)
479480
"Microsoft.VisualStudio.Component.Windows10SDK.18362";
480481
] )
481482
in

src-opam/windows.ml

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,33 +60,47 @@ let install_vc_redist ?(vs_version = "17") ?(arch = `X86_64) () =
6060
|> cleanup
6161

6262
let install_visual_studio_build_tools ?(vs_version = "17") components =
63-
let install =
64-
let fmt =
65-
format_of_string
66-
{|C:\TEMP\Install.cmd C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
67-
--installPath C:\BuildTools --channelUri C:\TEMP\VisualStudio.chman `
68-
--installChannelUri C:\TEMP\VisualStudio.chman%s|}
69-
in
70-
run fmt
71-
(List.fold_left
72-
(fun acc component -> acc ^ " `\n --add " ^ component)
73-
"" components)
63+
(* https://learn.microsoft.com/en-us/visualstudio/install/advanced-build-tools-container?view=vs-2022#dockerfile *)
64+
let excluded_components =
65+
(* Exclude workloads and components with known issues *)
66+
[
67+
"Microsoft.VisualStudio.Component.Windows10SDK.10240";
68+
"Microsoft.VisualStudio.Component.Windows10SDK.10586";
69+
"Microsoft.VisualStudio.Component.Windows10SDK.14393";
70+
"Microsoft.VisualStudio.Component.Windows81SDK";
71+
]
72+
in
73+
let pp cmd components =
74+
let buf = Buffer.create 512 in
75+
List.iter
76+
(fun component ->
77+
Buffer.add_string buf " `\n --";
78+
Buffer.add_string buf cmd;
79+
Buffer.add_char buf ' ';
80+
Buffer.add_string buf component)
81+
components;
82+
Buffer.contents buf
7483
in
75-
(* https://docs.microsoft.com/en-us/visualstudio/install/advanced-build-tools-container?view=vs-2019#install-script *)
7684
add
7785
~src:
7886
[
87+
(* https://learn.microsoft.com/en-us/visualstudio/install/advanced-build-tools-container?view=vs-2022#install-script *)
7988
"https://raw.githubusercontent.com/ocurrent/ocaml-dockerfile/master/src-opam/Install.cmd";
8089
]
8190
~dst:{|C:\TEMP\|} ()
8291
@@ add ~src:[ "https://aka.ms/vscollect.exe" ] ~dst:{|C:\TEMP\collect.exe|} ()
8392
@@ add
8493
~src:[ "https://aka.ms/vs/" ^ vs_version ^ "/release/channel" ]
8594
~dst:{|C:\TEMP\VisualStudio.chman|} ()
86-
@@ add
87-
~src:[ "https://aka.ms/vs/" ^ vs_version ^ "/release/vs_buildtools.exe" ]
88-
~dst:{|C:\TEMP\vs_buildtools.exe|} ()
89-
@@ install
95+
@@ run
96+
{|curl -SL --output C:\TEMP\vs_buildtools.exe https://aka.ms/vs/%s/release/vs_buildtools.exe `
97+
&& (call C:\TEMP\Install.cmd C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache install `
98+
--installPath "%%ProgramFiles(x86)%%\Microsoft Visual Studio\2022\BuildTools" `
99+
--channelUri C:\TEMP\VisualStudio.chman `
100+
--installChannelUri C:\TEMP\VisualStudio.chman%s%s) `
101+
&& del /q C:\TEMP\vs_buildtools.exe|}
102+
vs_version (pp "add" components)
103+
(pp "remove" excluded_components)
90104

91105
let header ~alias ?win10_revision
92106
?(version =

src-opam/windows.mli

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,17 @@ val sanitize_reg_path : unit -> t
5151
/usr/bin/bash: -c: line 1: syntax error: unexpected end of file
5252
v} |}]
5353

54-
val install_vc_redist : ?vs_version:string -> ?arch:Ocaml_version.arch -> unit -> t
54+
val install_vc_redist :
55+
?vs_version:string -> ?arch:Ocaml_version.arch -> unit -> t
5556
(** Install Microsoft Visual C++ Redistributable.
5657
@see <https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads> *)
5758

5859
val install_visual_studio_build_tools : ?vs_version:string -> string list -> t
5960
(** Install Visual Studio Build Tools components.
60-
@see <https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019> *)
61+
62+
@see <https://learn.microsoft.com/en-us/visualstudio/install/build-tools-container?view=vs-2022>
63+
@see <https://learn.microsoft.com/en-us/visualstudio/install/build-tools-container-issues?view=vs-2022>
64+
@see <https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022> *)
6165

6266
val ocaml_for_windows_package_exn :
6367
switch:Ocaml_version.t ->

0 commit comments

Comments
 (0)