Skip to content

Commit

Permalink
fix: ignore path modification error for MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Dec 6, 2021
1 parent 7092c4b commit 487a882
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/setup_cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/setup_cpp.js.map

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions src/msvc/msvc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { error } from "@actions/core"
import { setupVCVarsall } from "../vcvarsall/vcvarsall"
import { readFileSync } from "fs"

type MSVCVersion = "2015" | "2017" | "2019" | string

Expand Down Expand Up @@ -35,9 +34,13 @@ export async function setupMSVC(
VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133"
}
} catch (e) {
error(e as string | Error)
const choco_logs = readFileSync(`${process.env.ALLUSERSPROFILE}\\chocolatey\\logs\\chocolatey.log`, "utf8")
console.log(choco_logs)
if (
!(e as string | Error)
.toString()
.includes("Item has already been added. Key in dictionary: 'Path' Key being added: 'PATH'")
) {
error(e as string | Error)
}
}
// run vcvarsall.bat environment variables
setupVCVarsall(VCTargetsPath, arch, toolset, sdk, uwp, spectre)
Expand Down
3 changes: 2 additions & 1 deletion src/vcvarsall/vcvarsall.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { exportVariable } from "@actions/core"
import { exportVariable, info } from "@actions/core"
import { existsSync } from "fs"

function getArch(arch: string): string {
Expand Down Expand Up @@ -26,6 +26,7 @@ export function setupVCVarsall(
spectre?: boolean
) {
if (VCTargetsPath !== undefined && existsSync(VCTargetsPath)) {
info(`Adding ${VCTargetsPath} to PATH`)
exportVariable("VCTargetsPath", VCTargetsPath)
}

Expand Down

0 comments on commit 487a882

Please sign in to comment.