mirror of
https://github.com/microsoft/setup-msbuild.git
synced 2024-11-22 19:41:07 +07:00
Fix sync/async callback issue
This commit is contained in:
parent
5cf04033c1
commit
7d7af37b7e
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
|||||||
id: setup_msbuild
|
id: setup_msbuild
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
vs-version: "[16.4,16.6]"
|
vs-version: "[16.4,)"
|
||||||
|
|
||||||
- name: echo msbuild path
|
- name: echo msbuild path
|
||||||
run: echo "${{ steps.setup_msbuild.outputs.msbuildPath }}"
|
run: echo "${{ steps.setup_msbuild.outputs.msbuildPath }}"
|
||||||
|
30
dist/index.js
vendored
30
dist/index.js
vendored
@ -1919,6 +1919,7 @@ else {
|
|||||||
}
|
}
|
||||||
core.debug(`Execution arguments: ${VSWHERE_EXEC}`);
|
core.debug(`Execution arguments: ${VSWHERE_EXEC}`);
|
||||||
function run() {
|
function run() {
|
||||||
|
var _a;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
// exit if non Windows runner
|
// exit if non Windows runner
|
||||||
@ -1939,7 +1940,7 @@ function run() {
|
|||||||
core.debug(`Found tool in PATH: ${vsWhereInPath}`);
|
core.debug(`Found tool in PATH: ${vsWhereInPath}`);
|
||||||
vswhereToolExe = path.join(vsWhereInPath, 'vswhere.exe');
|
vswhereToolExe = path.join(vsWhereInPath, 'vswhere.exe');
|
||||||
}
|
}
|
||||||
catch (_a) {
|
catch (_b) {
|
||||||
// wasn't found because which threw
|
// wasn't found because which threw
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
@ -1947,28 +1948,25 @@ function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.debug(`Full tool exe: ${vswhereToolExe}`);
|
core.debug(`Full tool exe: ${vswhereToolExe}`);
|
||||||
let foundToolPath = '';
|
let installationPath = '';
|
||||||
const options = {};
|
const options = {};
|
||||||
options.listeners = {
|
options.listeners = {
|
||||||
stdout: (data) => {
|
stdout: (data) => {
|
||||||
const output = data.toString().trim();
|
installationPath = data.toString().trim();
|
||||||
core.debug(`Found installation path: ${output}`);
|
core.debug(`Found installation path: ${installationPath}`);
|
||||||
const pattern = `${output}\\\\MSBuild\\**\\Bin\\msbuild.exe`;
|
|
||||||
/* eslint-disable @typescript-eslint/promise-function-async */
|
|
||||||
glob
|
|
||||||
.create(pattern)
|
|
||||||
.then(globber => globber.glob())
|
|
||||||
.then(files => {
|
|
||||||
var _a;
|
|
||||||
if (((_a = files) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
||||||
foundToolPath = files[0];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/* eslint-enable @typescript-eslint/promise-function-async */
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// 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);
|
||||||
|
let foundToolPath = '';
|
||||||
|
if (installationPath) {
|
||||||
|
const pattern = `${installationPath}\\\\MSBuild\\**\\Bin\\msbuild.exe`;
|
||||||
|
const globber = yield glob.create(pattern);
|
||||||
|
const files = yield globber.glob();
|
||||||
|
if (((_a = files) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
||||||
|
foundToolPath = files[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!foundToolPath) {
|
if (!foundToolPath) {
|
||||||
core.setFailed('Unable to find msbuild.');
|
core.setFailed('Unable to find msbuild.');
|
||||||
return;
|
return;
|
||||||
|
31
src/main.ts
31
src/main.ts
@ -56,31 +56,30 @@ async function run(): Promise<void> {
|
|||||||
|
|
||||||
core.debug(`Full tool exe: ${vswhereToolExe}`)
|
core.debug(`Full tool exe: ${vswhereToolExe}`)
|
||||||
|
|
||||||
let foundToolPath = ''
|
let installationPath = ''
|
||||||
const options: ExecOptions = {}
|
const options: ExecOptions = {}
|
||||||
options.listeners = {
|
options.listeners = {
|
||||||
stdout: (data: Buffer) => {
|
stdout: (data: Buffer) => {
|
||||||
const output = data.toString().trim()
|
installationPath = data.toString().trim()
|
||||||
core.debug(`Found installation path: ${output}`)
|
core.debug(`Found installation path: ${installationPath}`)
|
||||||
|
|
||||||
const pattern = `${output}\\\\MSBuild\\**\\Bin\\msbuild.exe`
|
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/promise-function-async */
|
|
||||||
glob
|
|
||||||
.create(pattern)
|
|
||||||
.then(globber => globber.glob())
|
|
||||||
.then(files => {
|
|
||||||
if (files?.length > 0) {
|
|
||||||
foundToolPath = files[0]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
/* eslint-enable @typescript-eslint/promise-function-async */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
await exec.exec(`"${vswhereToolExe}" ${VSWHERE_EXEC}`, [], options)
|
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) {
|
if (!foundToolPath) {
|
||||||
core.setFailed('Unable to find msbuild.')
|
core.setFailed('Unable to find msbuild.')
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user