-
Notifications
You must be signed in to change notification settings - Fork 676
/
getMSBuildInfo.ts
32 lines (25 loc) · 1.14 KB
/
getMSBuildInfo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { join } from "path";
import { execChildProcess } from "../common";
import { CoreClrDebugUtil } from "../coreclr-debug/util";
export const MSBUILD_MISSING_MESSAGE = "A valid msbuild installation could not be found.";
let _msbuildVersion: string | undefined;
export async function getMSBuildVersion(): Promise<string | undefined> {
if (_msbuildVersion !== undefined) {
return _msbuildVersion;
}
const msbuildExeName = join('msbuild', CoreClrDebugUtil.getPlatformExeExtension());
try {
let data = await execChildProcess(`${msbuildExeName} --version --nologo`, process.cwd(), process.env);
const match = /^(\d+\.\d+\.\d+\.\d+)$/.exec(data);
if (match) {
_msbuildVersion = match[1];
}
}
catch {
}
return _msbuildVersion;
}