fix: catch msvc installation bugs

This commit is contained in:
Amin Yahyaabadi 2021-09-17 06:21:16 -05:00
parent 4285e7bb04
commit 5e6cf5d519
1 changed files with 29 additions and 21 deletions

View File

@ -1,6 +1,6 @@
import { setupMSVCDevCmd } from "./msvc-dev-cmd/index"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { exportVariable } from "@actions/core"
import { error, exportVariable } from "@actions/core"
import { existsSync } from "fs"
type MSVCVersion = "2015" | "2017" | "2019" | string
@ -34,28 +34,36 @@ export async function setupMSVC(
}
let toolset: string | undefined
let VCTargetsPath: string | undefined
if (version === "2015") {
toolset = "14.0.25420.1"
await setupChocoPack("visualcpp-build-tools", toolset, ["--ignore-dependencies", "--params", "'/IncludeRequired'"])
try {
if (version === "2015") {
toolset = "14.0.25420.1"
await setupChocoPack("visualcpp-build-tools", toolset, [
"--ignore-dependencies",
"--params",
"'/IncludeRequired'",
])
VCTargetsPath = "C:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/v140"
if (existsSync(VCTargetsPath)) {
exportVariable("VCTargetsPath", VCTargetsPath)
VCTargetsPath = "C:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/v140"
if (existsSync(VCTargetsPath)) {
exportVariable("VCTargetsPath", VCTargetsPath)
}
} else if (version === "2017") {
toolset = "14.16"
await setupChocoPack("visualstudio2017buildtools", "15.9.38.0", [
"--package-parameters",
"'--add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --passive'",
])
VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16" // TODO verify path
} else if (version === "2019") {
toolset = "14.29.30133"
await setupChocoPack("visualstudio2019buildtools", "16.11.2.0", [
"--package-parameters",
"'--add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --passive'",
])
VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133"
}
} else if (version === "2017") {
toolset = "14.16"
await setupChocoPack("visualstudio2017buildtools", "15.9.38.0", [
"--package-parameters",
"'--add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --passive'",
])
VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16" // TODO verify path
} else if (version === "2019") {
toolset = "14.29.30133"
await setupChocoPack("visualstudio2019buildtools", "16.11.2.0", [
"--package-parameters",
"'--add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --passive'",
])
VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133"
} catch (e) {
error(e as string | Error)
}
if (VCTargetsPath !== undefined && existsSync(VCTargetsPath)) {
exportVariable("VCTargetsPath", VCTargetsPath)