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 { setupMSVCDevCmd } from "./msvc-dev-cmd/index"
import { setupChocoPack } from "../utils/setup/setupChocoPack" import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { exportVariable } from "@actions/core" import { error, exportVariable } from "@actions/core"
import { existsSync } from "fs" import { existsSync } from "fs"
type MSVCVersion = "2015" | "2017" | "2019" | string type MSVCVersion = "2015" | "2017" | "2019" | string
@ -34,28 +34,36 @@ export async function setupMSVC(
} }
let toolset: string | undefined let toolset: string | undefined
let VCTargetsPath: string | undefined let VCTargetsPath: string | undefined
if (version === "2015") { try {
toolset = "14.0.25420.1" if (version === "2015") {
await setupChocoPack("visualcpp-build-tools", toolset, ["--ignore-dependencies", "--params", "'/IncludeRequired'"]) 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" VCTargetsPath = "C:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/v140"
if (existsSync(VCTargetsPath)) { if (existsSync(VCTargetsPath)) {
exportVariable("VCTargetsPath", 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") { } catch (e) {
toolset = "14.16" error(e as string | Error)
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"
} }
if (VCTargetsPath !== undefined && existsSync(VCTargetsPath)) { if (VCTargetsPath !== undefined && existsSync(VCTargetsPath)) {
exportVariable("VCTargetsPath", VCTargetsPath) exportVariable("VCTargetsPath", VCTargetsPath)