Compare commits

...

15 Commits

Author SHA1 Message Date
9546707e6b Fixing input warning message 2021-08-24 12:54:44 -07:00
f9e64ce582 Adding pre-release input flag 2021-08-24 12:51:38 -07:00
6387a9728e Merge branch 'Clancey-patch-1' 2021-08-24 12:45:51 -07:00
455ec54ae7 Always use -latest 2021-07-13 14:36:17 -08:00
4917605713 Allows vs-prerelease option Fixes #45 2021-07-13 13:31:52 -08:00
7561732237 Added an option for allow-prerelease 2021-07-13 13:22:52 -08:00
1982f45c48 Update README.md
Clarifying more that this is only for MSBuild
2021-03-15 08:05:45 -07:00
0e477eda77 Adding doc on release process 2020-10-06 09:20:39 -07:00
f032e55f3f Update readme to latest version 2020-10-06 08:57:14 -07:00
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
7 changed files with 204 additions and 43 deletions

View File

@ -1,11 +1,13 @@
# microsoft/setup-msbuild # microsoft/setup-msbuild
You know how handy that 'Visual Studio Developer Command Prompt' is on your local machine? And how it adds several things to `PATH` to allow you to just issue commands like `msbuild` or otherwise? Use this action to setup similar flexibility in your Windows-based GitHub Actions runners. This will let you discover where those tool paths are and automatically add them to the `PATH` environment variables for you so future steps in your Actions workflow can just initiate commands without knowing the full path. You know how handy that 'Visual Studio Developer Command Prompt' is on your local machine? And how it adds several things to `PATH` to allow you to just issue commands like `msbuild` or otherwise? Use this action to setup similar flexibility in your Windows-based GitHub Actions runners. This will let you discover where the `MSBuild` tool is and automatically add it to the `PATH` environment variables for you so future steps in your Actions workflow can just initiate `msbuild` commands without knowing the full path.
> Please note this tools is not to replicate the full 'Developer Command Prompt' but only discover and assist with MSBuild and not other tools like cl.exe
## Usage ## Usage
```yml ```yml
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.1 uses: microsoft/setup-msbuild@v1.0.3
``` ```
## Specifying specific versions of Visual Studio ## Specifying specific versions of Visual Studio
@ -13,21 +15,21 @@ You may have a situation where your Actions runner has multiple versions of Visu
```yml ```yml
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.1 uses: microsoft/setup-msbuild@v1.0.3
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. 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 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 ```yml
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.1 uses: microsoft/setup-msbuild@v1.0.3
with: with:
vswhere-path: 'C:\path\to\your\tools\' vswhere-path: 'C:\path\to\your\tools\'
``` ```
## Notes on arguments ## Notes on arguments

View File

@ -11,6 +11,9 @@ inputs:
vs-version: vs-version:
description: 'Version of Visual Studio to search; defaults to latest if not specified' description: 'Version of Visual Studio to search; defaults to latest if not specified'
required: false required: false
vs-prerelease:
description: 'Enable searching for pre-release versions of Visual Studio/MSBuild'
required: false
outputs: outputs:
msbuildPath: msbuildPath:
description: 'The resulting location of msbuild for your inputs' description: 'The resulting location of msbuild for your inputs'

29
building-release.md Normal file
View File

@ -0,0 +1,29 @@
# Building a release
This is a quick document to walk through the process of building and releasing.
## Building the version
- Create a new branch [vMajor.Minor.Revision] for the version from `dev`
- Make changes in the new branch
- Build the branch/package
- `npm install`
- `npm run build`
- `npm run package`
- Prune the dependencies to only production
- `npm prune --production`
- Uncomment `node_modules` in `.gitignore` **for this branch only**
- Commit the changes to the branch
- Push the new version branch
- `git push origin [vMajor.Minor.Revision]`
## Releasing the new version
- Draft a new release to [vMajor.Minor.Revision]
## Update major version tag
If the update is non-breaking and the major version binding you can update the version tag to make the new release available to those binding to the major version tag ([GitHub Actions Versioning](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)).
Do this from the version branch after push (using a v1 tag as example only here)
```
git tag -fa v1 -m "Update v1 tag"
git push origin v1 --force
```

180
dist/index.js vendored
View File

@ -934,6 +934,32 @@ class ExecState extends events.EventEmitter {
/***/ }), /***/ }),
/***/ 82:
/***/ (function(__unusedmodule, exports) {
"use strict";
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
*/
function toCommandValue(input) {
if (input === null || input === undefined) {
return '';
}
else if (typeof input === 'string' || input instanceof String) {
return input;
}
return JSON.stringify(input);
}
exports.toCommandValue = toCommandValue;
//# sourceMappingURL=utils.js.map
/***/ }),
/***/ 87: /***/ 87:
/***/ (function(module) { /***/ (function(module) {
@ -941,6 +967,42 @@ module.exports = require("os");
/***/ }), /***/ }),
/***/ 102:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
// For internal use, subject to change.
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
const fs = __importStar(__webpack_require__(747));
const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(82);
function issueCommand(command, message) {
const filePath = process.env[`GITHUB_${command}`];
if (!filePath) {
throw new Error(`Unable to find environment variable for file command ${command}`);
}
if (!fs.existsSync(filePath)) {
throw new Error(`Missing file at path: ${filePath}`);
}
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
encoding: 'utf8'
});
}
exports.issueCommand = issueCommand;
//# sourceMappingURL=file-command.js.map
/***/ }),
/***/ 129: /***/ 129:
/***/ (function(module) { /***/ (function(module) {
@ -978,8 +1040,12 @@ 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');
const ALLOW_PRERELEASE = core.getInput('vs-prerelease') || 'false';
// if a specific version of VS is requested // if a specific version of VS is requested
let VSWHERE_EXEC = '-products * -requires Microsoft.Component.MSBuild -property installationPath -latest '; let VSWHERE_EXEC = '-products * -requires Microsoft.Component.MSBuild -property installationPath -latest ';
if (ALLOW_PRERELEASE === 'true') {
VSWHERE_EXEC += ' -prerelease ';
}
if (VS_VERSION !== 'latest') { if (VS_VERSION !== 'latest') {
VSWHERE_EXEC += `-version "${VS_VERSION}" `; VSWHERE_EXEC += `-version "${VS_VERSION}" `;
} }
@ -1071,17 +1137,25 @@ module.exports = require("assert");
"use strict"; "use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const os = __webpack_require__(87); const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(82);
/** /**
* Commands * Commands
* *
* Command Format: * Command Format:
* ##[name key=value;key=value]message * ::name key=value,key=value::message
* *
* Examples: * Examples:
* ##[warning]This is the user warning message * ::warning::This is the message
* ##[set-secret name=mypassword]definitelyNotAPassword! * ::set-env name=MY_VAR::some value
*/ */
function issueCommand(command, properties, message) { function issueCommand(command, properties, message) {
const cmd = new Command(command, properties, message); const cmd = new Command(command, properties, message);
@ -1106,34 +1180,39 @@ class Command {
let cmdStr = CMD_STRING + this.command; let cmdStr = CMD_STRING + this.command;
if (this.properties && Object.keys(this.properties).length > 0) { if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += ' '; cmdStr += ' ';
let first = true;
for (const key in this.properties) { for (const key in this.properties) {
if (this.properties.hasOwnProperty(key)) { if (this.properties.hasOwnProperty(key)) {
const val = this.properties[key]; const val = this.properties[key];
if (val) { if (val) {
// safely append the val - avoid blowing up when attempting to if (first) {
// call .replace() if message is not a string for some reason first = false;
cmdStr += `${key}=${escape(`${val || ''}`)},`; }
else {
cmdStr += ',';
}
cmdStr += `${key}=${escapeProperty(val)}`;
} }
} }
} }
} }
cmdStr += CMD_STRING; cmdStr += `${CMD_STRING}${escapeData(this.message)}`;
// safely append the message - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason
const message = `${this.message || ''}`;
cmdStr += escapeData(message);
return cmdStr; return cmdStr;
} }
} }
function escapeData(s) { function escapeData(s) {
return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A'); return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A');
} }
function escape(s) { function escapeProperty(s) {
return s return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D') .replace(/\r/g, '%0D')
.replace(/\n/g, '%0A') .replace(/\n/g, '%0A')
.replace(/]/g, '%5D') .replace(/:/g, '%3A')
.replace(/;/g, '%3B'); .replace(/,/g, '%2C');
} }
//# sourceMappingURL=command.js.map //# sourceMappingURL=command.js.map
@ -1153,10 +1232,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = __webpack_require__(431); const command_1 = __webpack_require__(431);
const os = __webpack_require__(87); const file_command_1 = __webpack_require__(102);
const path = __webpack_require__(622); const utils_1 = __webpack_require__(82);
const os = __importStar(__webpack_require__(87));
const path = __importStar(__webpack_require__(622));
/** /**
* The code to exit an action * The code to exit an action
*/ */
@ -1177,11 +1265,21 @@ var ExitCode;
/** /**
* Sets env variable for this action and future actions in the job * Sets env variable for this action and future actions in the job
* @param name the name of the variable to set * @param name the name of the variable to set
* @param val the value of the variable * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
*/ */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function exportVariable(name, val) { function exportVariable(name, val) {
process.env[name] = val; const convertedVal = utils_1.toCommandValue(val);
command_1.issueCommand('set-env', { name }, val); process.env[name] = convertedVal;
const filePath = process.env['GITHUB_ENV'] || '';
if (filePath) {
const delimiter = '_GitHubActionsFileCommandDelimeter_';
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
file_command_1.issueCommand('ENV', commandValue);
}
else {
command_1.issueCommand('set-env', { name }, convertedVal);
}
} }
exports.exportVariable = exportVariable; exports.exportVariable = exportVariable;
/** /**
@ -1197,7 +1295,13 @@ exports.setSecret = setSecret;
* @param inputPath * @param inputPath
*/ */
function addPath(inputPath) { function addPath(inputPath) {
command_1.issueCommand('add-path', {}, inputPath); const filePath = process.env['GITHUB_PATH'] || '';
if (filePath) {
file_command_1.issueCommand('PATH', inputPath);
}
else {
command_1.issueCommand('add-path', {}, inputPath);
}
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
} }
exports.addPath = addPath; exports.addPath = addPath;
@ -1220,12 +1324,22 @@ exports.getInput = getInput;
* Sets the value of an output. * Sets the value of an output.
* *
* @param name name of the output to set * @param name name of the output to set
* @param value value to store * @param value value to store. Non-string values will be converted to a string via JSON.stringify
*/ */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setOutput(name, value) { function setOutput(name, value) {
command_1.issueCommand('set-output', { name }, value); command_1.issueCommand('set-output', { name }, value);
} }
exports.setOutput = setOutput; exports.setOutput = setOutput;
/**
* Enables or disables the echoing of commands into stdout for the rest of the step.
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
*
*/
function setCommandEcho(enabled) {
command_1.issue('echo', enabled ? 'on' : 'off');
}
exports.setCommandEcho = setCommandEcho;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// Results // Results
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@ -1242,6 +1356,13 @@ exports.setFailed = setFailed;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// Logging Commands // Logging Commands
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/**
* Gets whether Actions Step Debug is on or not
*/
function isDebug() {
return process.env['RUNNER_DEBUG'] === '1';
}
exports.isDebug = isDebug;
/** /**
* Writes debug message to user log * Writes debug message to user log
* @param message debug message * @param message debug message
@ -1252,18 +1373,18 @@ function debug(message) {
exports.debug = debug; exports.debug = debug;
/** /**
* Adds an error issue * Adds an error issue
* @param message error issue message * @param message error issue message. Errors will be converted to string via toString()
*/ */
function error(message) { function error(message) {
command_1.issue('error', message); command_1.issue('error', message instanceof Error ? message.toString() : message);
} }
exports.error = error; exports.error = error;
/** /**
* Adds an warning issue * Adds an warning issue
* @param message warning issue message * @param message warning issue message. Errors will be converted to string via toString()
*/ */
function warning(message) { function warning(message) {
command_1.issue('warning', message); command_1.issue('warning', message instanceof Error ? message.toString() : message);
} }
exports.warning = warning; exports.warning = warning;
/** /**
@ -1321,8 +1442,9 @@ exports.group = group;
* Saves state for current action, the state can only be retrieved by this action's post job execution. * Saves state for current action, the state can only be retrieved by this action's post job execution.
* *
* @param name name of the state to store * @param name name of the state to store
* @param value value to store * @param value value to store. Non-string values will be converted to a string via JSON.stringify
*/ */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function saveState(name, value) { function saveState(name, value) {
command_1.issueCommand('save-state', { name }, value); command_1.issueCommand('save-state', { name }, value);
} }

6
package-lock.json generated
View File

@ -5,9 +5,9 @@
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"@actions/core": { "@actions/core": {
"version": "1.2.0", "version": "1.2.6",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.0.tgz", "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
"integrity": "sha512-ZKdyhlSlyz38S6YFfPnyNgCDZuAF2T0Qv5eHflNWytPS8Qjvz39bZFMry9Bb/dpSnqWcNeav5yM2CTYpJeY+Dw==" "integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
}, },
"@actions/exec": { "@actions/exec": {
"version": "1.0.3", "version": "1.0.3",

View File

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

View File

@ -8,9 +8,14 @@ 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 = core.getInput('vswhere-path') const VSWHERE_PATH = core.getInput('vswhere-path')
const ALLOW_PRERELEASE = core.getInput('vs-prerelease') || 'false'
// if a specific version of VS is requested // if a specific version of VS is requested
let VSWHERE_EXEC = '-products * -requires Microsoft.Component.MSBuild -property installationPath -latest ' let VSWHERE_EXEC = '-products * -requires Microsoft.Component.MSBuild -property installationPath -latest '
if (ALLOW_PRERELEASE === 'true') {
VSWHERE_EXEC += ' -prerelease '
}
if (VS_VERSION !== 'latest') { if (VS_VERSION !== 'latest') {
VSWHERE_EXEC += `-version "${VS_VERSION}" ` VSWHERE_EXEC += `-version "${VS_VERSION}" `
} }