Compare commits

...

32 Commits
v1.0.0 ... dev

Author SHA1 Message Date
6a8fedefe9 Merge pull request #25 from microsoft/dependabot/npm_and_yarn/actions/core-1.2.6
Bump @actions/core from 1.2.0 to 1.2.6
2020-10-06 08:28:29 -07:00
a0858ffef3 Bump @actions/core from 1.2.0 to 1.2.6
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.0 to 1.2.6.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-01 17:33:54 +00:00
9fe8dba406 Merge pull request #23 from LanceMcCarthy/patch-1
Update README.md
2020-09-01 13:49:32 -07:00
0b5643901b Update README.md
Fixed incorrect indentation of `with` in examples
2020-09-01 16:38:21 -04:00
45346b5e09 Merge pull request #21 from kishorejangid/patch-1
Update README.md
2020-08-03 08:10:44 -07:00
06c9a7f31c Update README.md
Incorrect grammar
2020-08-01 18:15:15 +05:30
f25dd68be2 Merge branch 'dependabot/npm_and_yarn/lodash-4.17.19' into dev 2020-07-22 21:15:24 -07:00
3fedb575b0 Merge branch 'dev' into dependabot/npm_and_yarn/lodash-4.17.19 2020-07-22 21:15:13 -07:00
84ff5b46d8 Merge branch 'dependabot/npm_and_yarn/actions/http-client-1.0.8' into dev 2020-07-22 21:14:53 -07:00
e4874c190b Merge branch 'dependabot/npm_and_yarn/acorn-5.7.4' into dev 2020-07-22 21:14:33 -07:00
41a4f5dd79 Merge branch 'dev' into dependabot/npm_and_yarn/acorn-5.7.4 2020-07-22 21:14:17 -07:00
9c8b0140a4 Merge branch 'dev' into dependabot/npm_and_yarn/actions/http-client-1.0.8 2020-07-22 21:13:00 -07:00
57920ca044 Merge branch 'heaths-issue10' into dev 2020-07-22 20:55:48 -07:00
0d4f73260b Bump lodash from 4.17.15 to 4.17.19
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-20 00:55:11 +00:00
341cfb53e3 Bump @actions/http-client from 1.0.2 to 1.0.8
Bumps [@actions/http-client](https://github.com/actions/http-client) from 1.0.2 to 1.0.8.
- [Release notes](https://github.com/actions/http-client/releases)
- [Changelog](https://github.com/actions/http-client/blob/master/RELEASES.md)
- [Commits](https://github.com/actions/http-client/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2020-04-29 18:02:20 +00:00
c4f3bee2c4 Add tests for different path resolution 2020-04-21 17:04:39 -07:00
20e1303853 Fix tool lookup and revert logging 2020-04-21 16:57:28 -07:00
e9f4898311 Add more logging 2020-04-21 16:50:45 -07:00
9499ca8787 Fix path resolution
Looking for vswhere in the PATH was never triggered and had some bugs (like failing unconditionally if the code path was executed).
2020-04-21 16:27:45 -07:00
0ddbddf06e Quote vs-version example 2020-04-21 16:14:19 -07:00
80d0deb83b Use -latest and -version properly
Fixes #8
2020-04-21 15:46:27 -07:00
2f9b9c17d6 Use specific paths for faster lookup
Fixes #2
2020-04-21 15:38:49 -07:00
7d7af37b7e Fix sync/async callback issue 2020-04-21 15:38:49 -07:00
5cf04033c1 Use sync callback 2020-04-21 15:38:49 -07:00
f6890ff843 Fix typo 2020-04-21 15:38:49 -07:00
f486e795bf Add pull_request to Actions triggers 2020-04-21 15:38:49 -07:00
4652bfc96e Do not use newer -find parameter
Fixes #10
2020-04-21 15:38:49 -07:00
bb70c6a023 Find any product with MSBuild component
Fixes #7
2020-04-21 15:38:49 -07:00
dc59c705e4 Merge pull request #16 from microsoft/dev
Merge pull request #15 from microsoft/master
2020-04-21 13:22:43 -07:00
f05df80b32 Merge pull request #15 from microsoft/master
Adding remark about arguments in readme
2020-04-21 13:21:03 -07:00
43cd4ebaec Bump acorn from 5.7.3 to 5.7.4
Bumps [acorn](https://github.com/acornjs/acorn) from 5.7.3 to 5.7.4.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/5.7.3...5.7.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-03-26 15:44:00 +00:00
9c9a1a34a4 Adding remark about arguments in readme 2020-03-26 08:42:27 -07:00
6 changed files with 129 additions and 77 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.5]"
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,35 +3,40 @@ 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:
This makes use of the vswhere tool which is a tool 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\'
```
## Notes on arguments
While the Action enables you to specify a `vswhere` path as well as a `vs-version`, these are more advanced options and when using GitHub-hosted runners you should not need these and is recommended you don't specify them. Using these require you to fully understand the runner environment, updates to the tools on the runner, and can cause failures if you are out of sync. For GitHub-hosted runners, omitting these arguments is the preferred usage.
## 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

32
package-lock.json generated
View File

@ -1,13 +1,13 @@
{
"name": "setup-msbuild",
"version": "1.0.0",
"version": "1.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@actions/core": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.0.tgz",
"integrity": "sha512-ZKdyhlSlyz38S6YFfPnyNgCDZuAF2T0Qv5eHflNWytPS8Qjvz39bZFMry9Bb/dpSnqWcNeav5yM2CTYpJeY+Dw=="
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
},
"@actions/exec": {
"version": "1.0.3",
@ -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
}
}
@ -4365,9 +4365,9 @@
}
},
"lodash": {
"version": "4.17.15",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==",
"version": "4.17.19",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz",
"integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==",
"dev": true
},
"lodash.memoize": {

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",
@ -28,7 +28,7 @@
"author": "Microsoft",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.2.0",
"@actions/core": "^1.2.6",
"@actions/exec": "^1.0.3",
"@actions/tool-cache": "^1.3.0"
},

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
}