Merge branch 'dev' into dependabot/npm_and_yarn/lodash-4.17.19

This commit is contained in:
Tim Heuer 2020-07-22 21:15:13 -07:00
commit 3fedb575b0
6 changed files with 115 additions and 66 deletions

View File

@ -1,5 +1,10 @@
name: "build-test-dev"
on:
pull_request:
branches:
- dev
paths-ignore:
- '*.md'
push:
branches:
- dev
@ -12,14 +17,27 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Setup MSBuild
id: setup_msbuild
- name: Setup MSBuild (vswhere-path)
id: setup_msbuild_explicit
uses: ./
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
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
run: msbuild -version

View File

@ -3,27 +3,29 @@ You know how handy that 'Visual Studio Developer Command Prompt' is on your loca
## Usage
```
```yml
- 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
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
uses: microsoft/setup-msbuild@v1.0.0
uses: microsoft/setup-msbuild@v1.0.1
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?
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
uses: microsoft/setup-msbuild@v1.0.0
uses: microsoft/setup-msbuild@v1.0.1
with:
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
As with most GitHub Actions, this requires NodeJS development tools. After installing NodeJS, you can build this by executing:
```
```bash
npm install
npm run build
npm run pack

44
dist/index.js vendored
View File

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

20
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "setup-msbuild",
"version": "1.0.0",
"version": "1.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -18,9 +18,9 @@
}
},
"@actions/http-client": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.2.tgz",
"integrity": "sha512-ngdGx7aXM7i9BFT+7e3RWWAEt3bX4tKrdI5w5hf0wYpHz66u5Nw6AFSFXG5wzQyUQbkgeNRnJZyK2zciGqXgrQ==",
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.8.tgz",
"integrity": "sha512-G4JjJ6f9Hb3Zvejj+ewLLKLf99ZC+9v+yCxoYf9vSyH+WkzPLB2LuUtRMGNkooMqdugGBFStIKXOuvH1W+EctA==",
"requires": {
"tunnel": "0.0.6"
}
@ -662,9 +662,9 @@
"dev": true
},
"acorn": {
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.0.tgz",
"integrity": "sha512-gac8OEcQ2Li1dxIEWGZzsp2BitJxwkwcOm0zHAJLcPJaVvm58FRnk6RkuLRpU1EujipU2ZFODv2P9DLMfnV8mw==",
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz",
"integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==",
"dev": true
},
"acorn-globals": {
@ -4226,9 +4226,9 @@
},
"dependencies": {
"acorn": {
"version": "5.7.3",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz",
"integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==",
"version": "5.7.4",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz",
"integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==",
"dev": true
}
}

View File

@ -1,6 +1,6 @@
{
"name": "setup-msbuild",
"version": "1.0.0",
"version": "1.0.1",
"private": true,
"description": "Helps set up specific MSBuild tool into PATH for later usage.",
"main": "lib/main.js",
@ -11,7 +11,7 @@
"lint": "eslint src/**/*.ts",
"pack": "ncc build",
"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": {
"type": "git",

View File

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