Skip to content

Commit

Permalink
findvs: expand msbuild checking
Browse files Browse the repository at this point in the history
  • Loading branch information
mscdex committed Apr 22, 2023
1 parent f6abe74 commit 8e06a3d
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions lib/findvs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,36 @@ const VS_VERSIONS_MODERN = new Map([
}],
]);
const PACKAGES = {
msbuild: 'Microsoft.VisualStudio.VC.MSBuild.Base',
vctools: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
express: 'Microsoft.VisualStudio.WDExpress',
msbuild: /^Microsoft[.]VisualStudio[.]VC[.]MSBuild[.](?:v\d+[.])?Base$/i,
vctools: /^Microsoft[.]VisualStudio[.]Component[.]VC[.]Tools[.]x86[.]x64$/i,
express: /^Microsoft[.]VisualStudio[.]WDExpress$/i,
winsdk:
/^Microsoft[.]VisualStudio[.]Component[.]Windows(81|10|11)SDK(?:[.](\d+)(?:[.]Desktop.*)?)?$/,
};
const SDK_REG = 'HKLM\\Software\\Microsoft\\Microsoft SDKs\\Windows';
const SDK32_REG =
'HKLM\\Software\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows';

function checkRequiredPackages(packages) {
if (!Array.isArray(packages))
return false;

let foundMSBuild = false;
let foundVCTools = false;
let foundExpress = false;
for (const pkg of packages) {
if (!foundMSBuild && PACKAGES.msbuild.test(pkg))
foundMSBuild = true;
else if (!foundVCTools && PACKAGES.vctools.test(pkg))
foundVCTools = true;
else if (!foundExpress && PACKAGES.express.test(pkg))
foundExpress = true;

if (foundMSBuild && (foundVCTools || foundExpress))
return true;
}
}

// Sorts newest to oldest
function versionStringCompare(a, b) {
const splitA = a.split('.');
Expand Down Expand Up @@ -131,12 +151,8 @@ function findModernVS() {
const verInfo = VS_VERSIONS_MODERN.get(vsVer.major);
if (verInfo === undefined)
continue;
if (!Array.isArray(vs.packages)
|| !vs.packages.includes(PACKAGES.msbuild)
|| (!vs.packages.includes(PACKAGES.vctools)
&& !vs.packages.includes(PACKAGES.express))) {
if (!checkRequiredPackages(vs.packages))
continue;
}
const vsSDKs = [];
for (const pkg of vs.packages) {
let fullVersion;
Expand Down

0 comments on commit 8e06a3d

Please sign in to comment.