Skip to content

Commit

Permalink
Check for msbuild instead of %VisualStudioVersion%
Browse files Browse the repository at this point in the history
  • Loading branch information
rotu committed Aug 28, 2020
1 parent 5fd8d9d commit 69b22dd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 47 deletions.
32 changes: 10 additions & 22 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3264,31 +3264,19 @@ function execBashCommand(commandLine, commandPrefix, options, log_message) {
const message = log_message || `Invoking "bash -c '${bashScript}'`;
let toolRunnerCommandLine = "";
let toolRunnerCommandLineArgs = [];
if (isWindows && process.env.VisualStudioVersion) {
if (isWindows) {
const which_msbuild = yield io.which("msbuild");
if (!which_msbuild) {
//todo: mutate instead of copy
options = options || {};
options.env = options.env || {};
options.env.PATH =
(options.env.PATH + ";" || false) +
"%programfiles(x86)%Microsoft Visual Studio\\2019\\Enterprise\\MSBuild\\Current\\Bin";
}
toolRunnerCommandLine = "C:\\Program Files\\Git\\bin\\bash.exe";
toolRunnerCommandLineArgs = ["-c", bashScript];
}
else if (isWindows) {
toolRunnerCommandLine = "C:\\Windows\\system32\\cmd.exe";
// This passes the same flags to cmd.exe that "run:" in a workflow.
// https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell
// Except for /D, which disables the AutoRun functionality from command prompt
// and it blocks Python virtual environment activation if one configures it in
// the previous steps.
toolRunnerCommandLineArgs = [
"/E:ON",
"/V:OFF",
"/S",
"/C",
"call",
"%programfiles(x86)%\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat",
"amd64",
"&",
"C:\\Program Files\\Git\\bin\\bash.exe",
"-c",
bashScript,
];
}
else {
toolRunnerCommandLine = "bash";
toolRunnerCommandLineArgs = ["-c", bashScript];
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"url": "https://github.com/ros-tooling/action-ros-ci/issues"
},
"dependencies": {
"@actions/core": "^1.2.4",
"@actions/core": "^1.2.5",
"@actions/exec": "^1.0.4",
"@actions/github": "^4.0.0",
"@actions/io": "^1.0.1"
Expand Down
31 changes: 10 additions & 21 deletions src/action-ros-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,18 @@ export async function execBashCommand(

let toolRunnerCommandLine = "";
let toolRunnerCommandLineArgs: string[] = [];
if (isWindows && process.env.VisualStudioVersion) {
if (isWindows) {
const which_msbuild = await io.which("msbuild");
if (!which_msbuild) {
//todo: mutate instead of copy
options = options || {};
options.env = options.env || {};
options.env.PATH =
(options.env.PATH + ";" || "") +
"%programfiles(x86)%Microsoft Visual Studio\\2019\\Enterprise\\MSBuild\\Current\\Bin";
}
toolRunnerCommandLine = "C:\\Program Files\\Git\\bin\\bash.exe";
toolRunnerCommandLineArgs = ["-c", bashScript];
} else if (isWindows) {
toolRunnerCommandLine = "C:\\Windows\\system32\\cmd.exe";
// This passes the same flags to cmd.exe that "run:" in a workflow.
// https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell
// Except for /D, which disables the AutoRun functionality from command prompt
// and it blocks Python virtual environment activation if one configures it in
// the previous steps.
toolRunnerCommandLineArgs = [
"/E:ON",
"/V:OFF",
"/S",
"/C",
"call",
"%programfiles(x86)%\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat",
"amd64",
"&",
"C:\\Program Files\\Git\\bin\\bash.exe",
"-c",
bashScript,
];
} else {
toolRunnerCommandLine = "bash";
toolRunnerCommandLineArgs = ["-c", bashScript];
Expand Down

0 comments on commit 69b22dd

Please sign in to comment.