|
1 | 1 | import { setupMSVCDevCmd } from "./msvc-dev-cmd/index"
|
2 | 2 | import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
3 |
| -import { exportVariable } from "@actions/core" |
| 3 | +import { error, exportVariable } from "@actions/core" |
4 | 4 | import { existsSync } from "fs"
|
5 | 5 |
|
6 | 6 | type MSVCVersion = "2015" | "2017" | "2019" | string
|
@@ -34,28 +34,36 @@ export async function setupMSVC(
|
34 | 34 | }
|
35 | 35 | let toolset: string | undefined
|
36 | 36 | let VCTargetsPath: string | undefined
|
37 |
| - if (version === "2015") { |
38 |
| - toolset = "14.0.25420.1" |
39 |
| - await setupChocoPack("visualcpp-build-tools", toolset, ["--ignore-dependencies", "--params", "'/IncludeRequired'"]) |
| 37 | + try { |
| 38 | + if (version === "2015") { |
| 39 | + toolset = "14.0.25420.1" |
| 40 | + await setupChocoPack("visualcpp-build-tools", toolset, [ |
| 41 | + "--ignore-dependencies", |
| 42 | + "--params", |
| 43 | + "'/IncludeRequired'", |
| 44 | + ]) |
40 | 45 |
|
41 |
| - VCTargetsPath = "C:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/v140" |
42 |
| - if (existsSync(VCTargetsPath)) { |
43 |
| - exportVariable("VCTargetsPath", VCTargetsPath) |
| 46 | + VCTargetsPath = "C:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/v140" |
| 47 | + if (existsSync(VCTargetsPath)) { |
| 48 | + exportVariable("VCTargetsPath", VCTargetsPath) |
| 49 | + } |
| 50 | + } else if (version === "2017") { |
| 51 | + toolset = "14.16" |
| 52 | + await setupChocoPack("visualstudio2017buildtools", "15.9.38.0", [ |
| 53 | + "--package-parameters", |
| 54 | + "'--add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --passive'", |
| 55 | + ]) |
| 56 | + VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16" // TODO verify path |
| 57 | + } else if (version === "2019") { |
| 58 | + toolset = "14.29.30133" |
| 59 | + await setupChocoPack("visualstudio2019buildtools", "16.11.2.0", [ |
| 60 | + "--package-parameters", |
| 61 | + "'--add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --passive'", |
| 62 | + ]) |
| 63 | + VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133" |
44 | 64 | }
|
45 |
| - } else if (version === "2017") { |
46 |
| - toolset = "14.16" |
47 |
| - await setupChocoPack("visualstudio2017buildtools", "15.9.38.0", [ |
48 |
| - "--package-parameters", |
49 |
| - "'--add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --passive'", |
50 |
| - ]) |
51 |
| - VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16" // TODO verify path |
52 |
| - } else if (version === "2019") { |
53 |
| - toolset = "14.29.30133" |
54 |
| - await setupChocoPack("visualstudio2019buildtools", "16.11.2.0", [ |
55 |
| - "--package-parameters", |
56 |
| - "'--add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --passive'", |
57 |
| - ]) |
58 |
| - VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133" |
| 65 | + } catch (e) { |
| 66 | + error(e as string | Error) |
59 | 67 | }
|
60 | 68 | if (VCTargetsPath !== undefined && existsSync(VCTargetsPath)) {
|
61 | 69 | exportVariable("VCTargetsPath", VCTargetsPath)
|
|
0 commit comments