Use specific paths for faster lookup

Fixes #2
This commit is contained in:
Heath Stewart 2020-04-04 12:59:26 -07:00
parent 7d7af37b7e
commit 2f9b9c17d6
4 changed files with 45 additions and 2198 deletions

2185
dist/index.js vendored

File diff suppressed because it is too large Load Diff

17
package-lock.json generated
View File

@ -17,15 +17,6 @@
"@actions/io": "^1.0.1"
}
},
"@actions/glob": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.1.0.tgz",
"integrity": "sha512-lx8SzyQ2FE9+UUvjqY1f28QbTJv+w8qP7kHHbfQRhphrlcx0Mdmm1tZdGJzfxv1jxREa/sLW4Oy8CbGQKCJySA==",
"requires": {
"@actions/core": "^1.2.0",
"minimatch": "^3.0.4"
}
},
"@actions/http-client": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.2.tgz",
@ -981,7 +972,8 @@
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
},
"base": {
"version": "0.11.2",
@ -1051,6 +1043,7 @@
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -1325,7 +1318,8 @@
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
"contains-path": {
"version": "0.1.0",
@ -4509,6 +4503,7 @@
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
}

View File

@ -30,7 +30,6 @@
"dependencies": {
"@actions/core": "^1.2.0",
"@actions/exec": "^1.0.3",
"@actions/glob": "^0.1.0",
"@actions/tool-cache": "^1.3.0"
},
"devDependencies": {

View File

@ -1,6 +1,6 @@
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as glob from '@actions/glob'
import * as fs from 'fs'
import * as path from 'path'
import * as io from '@actions/io'
import {ExecOptions} from '@actions/exec/lib/interfaces'
@ -56,32 +56,40 @@ async function run(): Promise<void> {
core.debug(`Full tool exe: ${vswhereToolExe}`)
let installationPath = ''
let foundToolPath = ''
const options: ExecOptions = {}
options.listeners = {
stdout: (data: Buffer) => {
installationPath = data.toString().trim()
const installationPath = data.toString().trim()
core.debug(`Found installation path: ${installationPath}`)
let toolPath = path.join(
installationPath,
'MSBuild\\Current\\Bin\\MSBuild.exe'
)
core.debug(`Checking for path: ${toolPath}`)
if (!fs.existsSync(toolPath)) {
toolPath = path.join(
installationPath,
'MSBuild\\15.0\\Bin\\MSBuild.exe'
)
core.debug(`Checking for path: ${toolPath}`)
if (!fs.existsSync(toolPath)) {
return
}
}
foundToolPath = toolPath
}
}
// execute the find putting the result of the command in the options foundToolPath
await exec.exec(`"${vswhereToolExe}" ${VSWHERE_EXEC}`, [], options)
let foundToolPath = ''
if (installationPath) {
const pattern = `${installationPath}\\\\MSBuild\\**\\Bin\\msbuild.exe`
const globber = await glob.create(pattern)
const files = await globber.glob()
if (files?.length > 0) {
foundToolPath = files[0]
}
}
if (!foundToolPath) {
core.setFailed('Unable to find msbuild.')
core.setFailed('Unable to find MSBuild.')
return
}