Merge branch 'dev' into dependabot/npm_and_yarn/acorn-5.7.4

This commit is contained in:
Tim Heuer 2020-07-22 21:14:17 -07:00
commit 41a4f5dd79
6 changed files with 106 additions and 57 deletions

View File

@ -1,5 +1,10 @@
name: "build-test-dev" name: "build-test-dev"
on: on:
pull_request:
branches:
- dev
paths-ignore:
- '*.md'
push: push:
branches: branches:
- dev - dev
@ -12,14 +17,27 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Setup MSBuild - name: Setup MSBuild (vswhere-path)
id: setup_msbuild id: setup_msbuild_explicit
uses: ./ uses: ./
with: with:
vs-version: "[16.4,16.6]" vswhere-path: C:\ProgramData\chocolatey\bin
- name: Setup MSBuild (PATH)
id: setup_msbuild_path
uses: ./
- name: Setup MSBuild (fallback)
id: setup_msbuild_fallback
uses: ./
env:
PATH: ''
- name: echo msbuild path - name: echo msbuild path
run: echo "${{ steps.setup_msbuild.outputs.msbuildPath }}" run: |
echo "vswhere-path: ${{ steps.setup_msbuild_explicit.outputs.msbuildPath }}"
echo "PATH: ${{ steps.setup_msbuild_path.outputs.msbuildPath }}"
echo "Fallback: ${{ steps.setup_msbuild_fallback.outputs.msbuildPath }}"
- name: echo MSBuild - name: echo MSBuild
run: msbuild -version run: msbuild -version

View File

@ -3,27 +3,29 @@ You know how handy that 'Visual Studio Developer Command Prompt' is on your loca
## Usage ## Usage
``` ```yml
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.0 uses: microsoft/setup-msbuild@v1.0.1
``` ```
## Specifying specific versions of Visual Studio ## Specifying specific versions of Visual Studio
You may have a situation where your Actions runner has multiple versions of Visual Studio and you need to find a specific version of the tool. Simply add the `vs-version` input to specify the range of versions to find. If looking for a specific version, enter that version number twice as a range. You may have a situation where your Actions runner has multiple versions of Visual Studio and you need to find a specific version of the tool. Simply add the `vs-version` input to specify the range of versions to find. If looking for a specific version, specify the minimum and maximum versions as shown in the example below, which will look for just 16.4.
``` ```yml
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.0 uses: microsoft/setup-msbuild@v1.0.1
with: with:
vs-version: [16.4,16.5] vs-version: '[16.4,16.5)'
``` ```
The syntax is the same used for Visual Studio extensions, where square brackets like "[" mean inclusive, and parenthesis like "(" mean exclusive. A comma is always required, but eliding the minimum version looks for all older versions and eliding the maximum version looks for all newer versions. See the [vswhere wiki](https://github.com/microsoft/vswhere/wiki) for more details.
## How does this work? ## How does this work?
This makes use of the vswhere tool which is a tool is delivered by Microsoft to help in identifying Visual Studio installs and various components. This tool is installed on the hosted Windows runners for GitHub Actions. If you are using a self-hosted runner, you either need to make sure vswhere.exe is in your agent's PATH or specify a full path to the location using: This makes use of the vswhere tool which is a tool is delivered by Microsoft to help in identifying Visual Studio installs and various components. This tool is installed on the hosted Windows runners for GitHub Actions. If you are using a self-hosted runner, you either need to make sure vswhere.exe is in your agent's PATH or specify a full path to the location using:
``` ```yml
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.0 uses: microsoft/setup-msbuild@v1.0.1
with: with:
vswhere-path: 'C:\path\to\your\tools\' vswhere-path: 'C:\path\to\your\tools\'
``` ```
@ -34,7 +36,7 @@ While the Action enables you to specify a `vswhere` path as well as a `vs-versio
## Building this repo ## Building this repo
As with most GitHub Actions, this requires NodeJS development tools. After installing NodeJS, you can build this by executing: As with most GitHub Actions, this requires NodeJS development tools. After installing NodeJS, you can build this by executing:
``` ```bash
npm install npm install
npm run build npm run build
npm run pack npm run pack

46
dist/index.js vendored
View File

@ -972,22 +972,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(__webpack_require__(470)); const core = __importStar(__webpack_require__(470));
const exec = __importStar(__webpack_require__(986)); const exec = __importStar(__webpack_require__(986));
const fs = __importStar(__webpack_require__(747));
const path = __importStar(__webpack_require__(622)); const path = __importStar(__webpack_require__(622));
const io = __importStar(__webpack_require__(1)); const io = __importStar(__webpack_require__(1));
const IS_WINDOWS = process.platform === 'win32'; const IS_WINDOWS = process.platform === 'win32';
const VS_VERSION = core.getInput('vs-version') || 'latest'; const VS_VERSION = core.getInput('vs-version') || 'latest';
const VSWHERE_PATH = core.getInput('vswhere-path') || const VSWHERE_PATH = core.getInput('vswhere-path');
path.join(process.env['ProgramFiles(x86)'], 'Microsoft Visual Studio\\Installer');
// if a specific version of VS is requested // if a specific version of VS is requested
let VSWHERE_EXEC = ''; let VSWHERE_EXEC = '-products * -requires Microsoft.Component.MSBuild -property installationPath -latest ';
if (VS_VERSION === 'latest') { if (VS_VERSION !== 'latest') {
VSWHERE_EXEC += '-latest '; VSWHERE_EXEC += `-version "${VS_VERSION}" `;
} }
else {
VSWHERE_EXEC += `-version ${VS_VERSION} `;
}
VSWHERE_EXEC +=
'-requires Microsoft.Component.MSBuild -find MSBuild\\**\\Bin\\MSBuild.exe';
core.debug(`Execution arguments: ${VSWHERE_EXEC}`); core.debug(`Execution arguments: ${VSWHERE_EXEC}`);
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
@ -1001,6 +996,7 @@ function run() {
let vswhereToolExe = ''; let vswhereToolExe = '';
if (VSWHERE_PATH) { if (VSWHERE_PATH) {
// specified a path for vswhere, use it // specified a path for vswhere, use it
core.debug(`Using given vswhere-path: ${VSWHERE_PATH}`);
vswhereToolExe = path.join(VSWHERE_PATH, 'vswhere.exe'); vswhereToolExe = path.join(VSWHERE_PATH, 'vswhere.exe');
} }
else { else {
@ -1008,29 +1004,41 @@ function run() {
try { try {
const vsWhereInPath = yield io.which('vswhere', true); const vsWhereInPath = yield io.which('vswhere', true);
core.debug(`Found tool in PATH: ${vsWhereInPath}`); core.debug(`Found tool in PATH: ${vsWhereInPath}`);
vswhereToolExe = path.join(vsWhereInPath, 'vswhere.exe'); vswhereToolExe = vsWhereInPath;
} }
catch (_a) { catch (_a) {
// wasn't found because which threw // fall back to VS-installed path
} vswhereToolExe = path.join(process.env['ProgramFiles(x86)'], 'Microsoft Visual Studio\\Installer\\vswhere.exe');
finally { core.debug(`Trying Visual Studio-installed path: ${vswhereToolExe}`);
core.setFailed('setup-msbuild requires the path to where vswhere.exe exists');
} }
} }
if (!fs.existsSync(vswhereToolExe)) {
core.setFailed('setup-msbuild requires the path to where vswhere.exe exists');
return;
}
core.debug(`Full tool exe: ${vswhereToolExe}`); core.debug(`Full tool exe: ${vswhereToolExe}`);
let foundToolPath = ''; let foundToolPath = '';
const options = {}; const options = {};
options.listeners = { options.listeners = {
stdout: (data) => { stdout: (data) => {
// eslint-disable-next-line prefer-const const installationPath = data.toString().trim();
let output = data.toString(); core.debug(`Found installation path: ${installationPath}`);
foundToolPath += output; 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 // execute the find putting the result of the command in the options foundToolPath
yield exec.exec(`"${vswhereToolExe}" ${VSWHERE_EXEC}`, [], options); yield exec.exec(`"${vswhereToolExe}" ${VSWHERE_EXEC}`, [], options);
if (!foundToolPath) { if (!foundToolPath) {
core.setFailed('Unable to find msbuild.'); core.setFailed('Unable to find MSBuild.');
return; return;
} }
// extract the folder location for the tool // extract the folder location for the tool

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "setup-msbuild", "name": "setup-msbuild",
"version": "1.0.0", "version": "1.0.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "setup-msbuild", "name": "setup-msbuild",
"version": "1.0.0", "version": "1.0.1",
"private": true, "private": true,
"description": "Helps set up specific MSBuild tool into PATH for later usage.", "description": "Helps set up specific MSBuild tool into PATH for later usage.",
"main": "lib/main.js", "main": "lib/main.js",
@ -11,7 +11,7 @@
"lint": "eslint src/**/*.ts", "lint": "eslint src/**/*.ts",
"pack": "ncc build", "pack": "ncc build",
"test": "jest", "test": "jest",
"all": "npm run build && npm run format && npm run lint && npm run pack && npm test" "all": "npm run build && npm run format && npm run lint && npm run pack"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -1,27 +1,19 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import * as exec from '@actions/exec' import * as exec from '@actions/exec'
import * as fs from 'fs'
import * as path from 'path' import * as path from 'path'
import * as io from '@actions/io' import * as io from '@actions/io'
import {ExecOptions} from '@actions/exec/lib/interfaces' import {ExecOptions} from '@actions/exec/lib/interfaces'
const IS_WINDOWS = process.platform === 'win32' const IS_WINDOWS = process.platform === 'win32'
const VS_VERSION = core.getInput('vs-version') || 'latest' const VS_VERSION = core.getInput('vs-version') || 'latest'
const VSWHERE_PATH = const VSWHERE_PATH = core.getInput('vswhere-path')
core.getInput('vswhere-path') ||
path.join(
process.env['ProgramFiles(x86)'] as string,
'Microsoft Visual Studio\\Installer'
)
// if a specific version of VS is requested // if a specific version of VS is requested
let VSWHERE_EXEC = '' let VSWHERE_EXEC = '-products * -requires Microsoft.Component.MSBuild -property installationPath -latest '
if (VS_VERSION === 'latest') { if (VS_VERSION !== 'latest') {
VSWHERE_EXEC += '-latest ' VSWHERE_EXEC += `-version "${VS_VERSION}" `
} else {
VSWHERE_EXEC += `-version ${VS_VERSION} `
} }
VSWHERE_EXEC +=
'-requires Microsoft.Component.MSBuild -find MSBuild\\**\\Bin\\MSBuild.exe'
core.debug(`Execution arguments: ${VSWHERE_EXEC}`) core.debug(`Execution arguments: ${VSWHERE_EXEC}`)
@ -38,31 +30,60 @@ async function run(): Promise<void> {
if (VSWHERE_PATH) { if (VSWHERE_PATH) {
// specified a path for vswhere, use it // specified a path for vswhere, use it
core.debug(`Using given vswhere-path: ${VSWHERE_PATH}`)
vswhereToolExe = path.join(VSWHERE_PATH, 'vswhere.exe') vswhereToolExe = path.join(VSWHERE_PATH, 'vswhere.exe')
} else { } else {
// check in PATH to see if it is there // check in PATH to see if it is there
try { try {
const vsWhereInPath: string = await io.which('vswhere', true) const vsWhereInPath: string = await io.which('vswhere', true)
core.debug(`Found tool in PATH: ${vsWhereInPath}`) core.debug(`Found tool in PATH: ${vsWhereInPath}`)
vswhereToolExe = path.join(vsWhereInPath, 'vswhere.exe') vswhereToolExe = vsWhereInPath
} catch { } catch {
// wasn't found because which threw // fall back to VS-installed path
} finally { vswhereToolExe = path.join(
core.setFailed( process.env['ProgramFiles(x86)'] as string,
'setup-msbuild requires the path to where vswhere.exe exists' 'Microsoft Visual Studio\\Installer\\vswhere.exe'
) )
core.debug(`Trying Visual Studio-installed path: ${vswhereToolExe}`)
} }
} }
if (!fs.existsSync(vswhereToolExe)) {
core.setFailed(
'setup-msbuild requires the path to where vswhere.exe exists'
)
return
}
core.debug(`Full tool exe: ${vswhereToolExe}`) core.debug(`Full tool exe: ${vswhereToolExe}`)
let foundToolPath = '' let foundToolPath = ''
const options: ExecOptions = {} const options: ExecOptions = {}
options.listeners = { options.listeners = {
stdout: (data: Buffer) => { stdout: (data: Buffer) => {
// eslint-disable-next-line prefer-const const installationPath = data.toString().trim()
let output = data.toString() core.debug(`Found installation path: ${installationPath}`)
foundToolPath += output
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
} }
} }
@ -70,7 +91,7 @@ async function run(): Promise<void> {
await exec.exec(`"${vswhereToolExe}" ${VSWHERE_EXEC}`, [], options) await exec.exec(`"${vswhereToolExe}" ${VSWHERE_EXEC}`, [], options)
if (!foundToolPath) { if (!foundToolPath) {
core.setFailed('Unable to find msbuild.') core.setFailed('Unable to find MSBuild.')
return return
} }