mirror of
https://github.com/microsoft/setup-msbuild.git
synced 2024-11-22 19:41:07 +07:00
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).
This commit is contained in:
parent
0ddbddf06e
commit
9499ca8787
14
dist/index.js
vendored
14
dist/index.js
vendored
@ -977,8 +977,7 @@ 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 = '-products * -requires Microsoft.Component.MSBuild -property installationPath -latest ';
|
let VSWHERE_EXEC = '-products * -requires Microsoft.Component.MSBuild -property installationPath -latest ';
|
||||||
if (VS_VERSION !== 'latest') {
|
if (VS_VERSION !== 'latest') {
|
||||||
@ -1007,11 +1006,16 @@ function run() {
|
|||||||
vswhereToolExe = path.join(vsWhereInPath, 'vswhere.exe');
|
vswhereToolExe = path.join(vsWhereInPath, 'vswhere.exe');
|
||||||
}
|
}
|
||||||
catch (_a) {
|
catch (_a) {
|
||||||
// wasn't found because which threw
|
// check for VS-installed path
|
||||||
|
const vsWhereInInstallerPath = path.join(process.env['ProgramFiles(x86)'], 'Microsoft Visual Studio\\Installer\\vswhere.exe');
|
||||||
|
if (fs.existsSync(vsWhereInInstallerPath)) {
|
||||||
|
vswhereToolExe = vsWhereInInstallerPath;
|
||||||
}
|
}
|
||||||
finally {
|
}
|
||||||
|
}
|
||||||
|
if (!fs.existsSync(vswhereToolExe)) {
|
||||||
core.setFailed('setup-msbuild requires the path to where vswhere.exe exists');
|
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 = '';
|
||||||
|
25
src/main.ts
25
src/main.ts
@ -7,12 +7,7 @@ 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 = '-products * -requires Microsoft.Component.MSBuild -property installationPath -latest '
|
let VSWHERE_EXEC = '-products * -requires Microsoft.Component.MSBuild -property installationPath -latest '
|
||||||
@ -43,12 +38,24 @@ async function run(): Promise<void> {
|
|||||||
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 {
|
} catch {
|
||||||
// wasn't found because which threw
|
// check for VS-installed path
|
||||||
} finally {
|
const vsWhereInInstallerPath = path.join(
|
||||||
|
process.env['ProgramFiles(x86)'] as string,
|
||||||
|
'Microsoft Visual Studio\\Installer\\vswhere.exe'
|
||||||
|
)
|
||||||
|
|
||||||
|
if (fs.existsSync(vsWhereInInstallerPath)) {
|
||||||
|
vswhereToolExe = vsWhereInInstallerPath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fs.existsSync(vswhereToolExe)) {
|
||||||
core.setFailed(
|
core.setFailed(
|
||||||
'setup-msbuild requires the path to where vswhere.exe exists'
|
'setup-msbuild requires the path to where vswhere.exe exists'
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
core.debug(`Full tool exe: ${vswhereToolExe}`)
|
core.debug(`Full tool exe: ${vswhereToolExe}`)
|
||||||
|
Loading…
Reference in New Issue
Block a user