Check default vswhere location too (#19)

On some self-hosted runners "vswhere" is not available in the PATH.
Add another check in the findWithVswhere() function. It checks the
default installation of vswhere as stated by Microsoft, just in case
it is there but just not in the PATH.

Furthermore, the check refers to non-existent method core.warn()
instead of core.warning(). Use the correct method for reporting.
This commit is contained in:
Nicolas Jarnoux
2020-10-18 11:38:45 +01:00
committed by GitHub
parent 840499b504
commit 75fbadd7d3
+15 -4
View File
@@ -4,9 +4,13 @@ const exec = require('util').promisify(child_process.exec)
const fs = require('fs')
const process = require('process')
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 InterestingVariables = [
'INCLUDE',
'LIB',
@@ -24,8 +28,16 @@ function findWithVswhere(pattern) {
let installationPath = child_process.execSync(`vswhere -products * -latest -prerelease -property installationPath`).toString().trim()
return installationPath + '\\' + pattern
} catch (e) {
core.warn(`vswhere failed: ${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
}
@@ -39,10 +51,9 @@ function findVcvarsall() {
// If that does not work, try the standard installation locations,
// starting with the latest and moving to the oldest.
const programFiles = process.env['ProgramFiles(x86)']
for (const ver of VERSIONS) {
for (const ed of EDITIONS) {
path = `${programFiles}\\Microsoft Visual Studio\\${ver}\\${ed}\\VC\\Auxiliary\\Build\\vcvarsall.bat`
path = `${PROGRAM_FILES_X86}\\Microsoft Visual Studio\\${ver}\\${ed}\\VC\\Auxiliary\\Build\\vcvarsall.bat`
if (fs.existsSync(path)) {
core.debug(`found standard location: ${path}`)
return path
@@ -51,7 +62,7 @@ function findVcvarsall() {
}
// Special case for Visual Studio 2015 (and maybe earlier), try it out too.
path = `${programFiles}\\Microsoft Visual C++ Build Tools\\vcbuildtools.bat`
path = `${PROGRAM_FILES_X86}\\Microsoft Visual C++ Build Tools\\vcbuildtools.bat`
if (fs.existsSync(path)) {
core.debug(`found VS 2015: ${path}`)
return path