|
1 | 1 | import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
2 |
| -import { error, exportVariable } from "@actions/core" |
| 2 | +import { error, exportVariable, warning } from "@actions/core" |
3 | 3 | import { existsSync } from "fs"
|
| 4 | +import { isCI } from "../utils/env/isci" |
4 | 5 |
|
5 | 6 | type MSVCVersion = "2015" | "2017" | "2019" | string
|
6 | 7 |
|
@@ -33,37 +34,43 @@ export async function setupMSVC(
|
33 | 34 | }
|
34 | 35 | let toolset: string | undefined
|
35 | 36 | let VCTargetsPath: string | undefined
|
36 |
| - try { |
37 |
| - if (version === "2015") { |
38 |
| - toolset = "14.0.25420.1" |
39 |
| - await setupChocoPack("visualcpp-build-tools", toolset, [ |
40 |
| - "--ignore-dependencies", |
41 |
| - "--params", |
42 |
| - "'/IncludeRequired'", |
43 |
| - ]) |
| 37 | + if (!isCI()) { |
| 38 | + // TODO enable this code path once its bugs are fixed |
| 39 | + // https://github.com/aminya/setup-cpp/issues/1 |
| 40 | + warning("Installing MSVC is experimental and known to fail.") |
| 41 | + try { |
| 42 | + if (version === "2015") { |
| 43 | + toolset = "14.0.25420.1" |
| 44 | + await setupChocoPack("visualcpp-build-tools", toolset, [ |
| 45 | + "--ignore-dependencies", |
| 46 | + "--params", |
| 47 | + "'/IncludeRequired'", |
| 48 | + ]) |
44 | 49 |
|
45 |
| - VCTargetsPath = "C:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/v140" |
46 |
| - if (existsSync(VCTargetsPath)) { |
47 |
| - exportVariable("VCTargetsPath", VCTargetsPath) |
| 50 | + VCTargetsPath = "C:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/v140" |
| 51 | + if (existsSync(VCTargetsPath)) { |
| 52 | + exportVariable("VCTargetsPath", VCTargetsPath) |
| 53 | + } |
| 54 | + } else if (version === "2017") { |
| 55 | + toolset = "14.16" |
| 56 | + await setupChocoPack("visualstudio2017buildtools", "15.9.38.0", [ |
| 57 | + "--package-parameters", |
| 58 | + "'--add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --passive'", |
| 59 | + ]) |
| 60 | + VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16" // TODO verify path |
| 61 | + } else if (version === "2019") { |
| 62 | + toolset = "14.29.30133" |
| 63 | + await setupChocoPack("visualstudio2019buildtools", "16.11.2.0", [ |
| 64 | + "--package-parameters", |
| 65 | + "'--add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --passive'", |
| 66 | + ]) |
| 67 | + VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133" |
48 | 68 | }
|
49 |
| - } else if (version === "2017") { |
50 |
| - toolset = "14.16" |
51 |
| - await setupChocoPack("visualstudio2017buildtools", "15.9.38.0", [ |
52 |
| - "--package-parameters", |
53 |
| - "'--add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --passive'", |
54 |
| - ]) |
55 |
| - VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16" // TODO verify path |
56 |
| - } else if (version === "2019") { |
57 |
| - toolset = "14.29.30133" |
58 |
| - await setupChocoPack("visualstudio2019buildtools", "16.11.2.0", [ |
59 |
| - "--package-parameters", |
60 |
| - "'--add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --passive'", |
61 |
| - ]) |
62 |
| - VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133" |
| 69 | + } catch (e) { |
| 70 | + error(e as string | Error) |
63 | 71 | }
|
64 |
| - } catch (e) { |
65 |
| - error(e as string | Error) |
66 | 72 | }
|
| 73 | + // run vcvarsall.bat environment variables |
67 | 74 | activateMSVC(VCTargetsPath, arch, toolset, sdk, uwp, spectre)
|
68 | 75 | }
|
69 | 76 |
|
|
0 commit comments