Skip to content

Commit 5e6cf5d

Browse files
committed
fix: catch msvc installation bugs
1 parent 4285e7b commit 5e6cf5d

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

src/msvc/msvc.ts

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { setupMSVCDevCmd } from "./msvc-dev-cmd/index"
22
import { setupChocoPack } from "../utils/setup/setupChocoPack"
3-
import { exportVariable } from "@actions/core"
3+
import { error, exportVariable } from "@actions/core"
44
import { existsSync } from "fs"
55

66
type MSVCVersion = "2015" | "2017" | "2019" | string
@@ -34,28 +34,36 @@ export async function setupMSVC(
3434
}
3535
let toolset: string | undefined
3636
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+
])
4045

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"
4464
}
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)
5967
}
6068
if (VCTargetsPath !== undefined && existsSync(VCTargetsPath)) {
6169
exportVariable("VCTargetsPath", VCTargetsPath)

0 commit comments

Comments
 (0)