From d9df5e2567e58eb1da77cbfd5177ab6245d117c7 Mon Sep 17 00:00:00 2001 From: Alexei Lozovsky Date: Sun, 13 Dec 2020 14:49:04 +0900 Subject: [PATCH] Add default vswhere location to PATH (#20) Instead of checking "vswhere" in PATH and then in the default location explicitly, just add the default locatio to PATH. That makes a single attempt sufficient. --- index.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 8205e05..1711ae1 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ const core = require('@actions/core') const child_process = require('child_process') const exec = require('util').promisify(child_process.exec) const fs = require('fs') +const path = require('path') const process = require('process') const PROGRAM_FILES_X86 = process.env['ProgramFiles(x86)'] @@ -9,7 +10,7 @@ const PROGRAM_FILES_X86 = process.env['ProgramFiles(x86)'] const EDITIONS = ['Enterprise', 'Professional', 'Community'] const VERSIONS = ['2019', '2017'] -const VSWHERE = `${PROGRAM_FILES_X86}\\Microsoft Visual Studio\\Installer\\vswhere.exe` +const VSWHERE_PATH = `${PROGRAM_FILES_X86}\\Microsoft Visual Studio\\Installer` const InterestingVariables = [ 'INCLUDE', @@ -31,14 +32,6 @@ function findWithVswhere(pattern) { } catch (e) { core.warning(`vswhere failed: ${e}`) } - - try { - let installationPath = child_process.execSync(`${VSWHERE} -products * -latest -prerelease -property installationPath`).toString().trim() - return installationPath + '\\' + pattern - } catch (e) { - core.warning(`vswhere failed: ${e}`) - } - return null } @@ -78,6 +71,9 @@ async function main() { return } + // Add standard location of "vswhere" to PATH, in case it's not there. + process.env.PATH += path.delimiter + VSWHERE_PATH + const arch = core.getInput('arch') const sdk = core.getInput('sdk') const toolset = core.getInput('toolset')