vscode-cmake-tools
vscode-cmake-tools copied to clipboard
Getting VS Kit Environment fails silently when VS instance not found
Brief Issue Summary
I've been using the CMake Tools extension with the Visual Studio generator for some time without issue. I swapped to using Ninja and was struggling with it using the wrong compiler. After enabling debug logging I found that this was because the environment variables from vcvaralls.bat were not being applied. I had to debug the vscode-cmake-tools extension to work out that the reason why was that at some point my VS Install instance ID had changed so my cmake-tools-kits.json was outdated. Running Scan for Kit updated the instance ID which fixed the issue.
It would be good if there were some kind of warning or error message when the VS instance was not found, and perhaps a suggestion to re-scan for kits:
export async function getVSKitEnvironment(kit: Kit): Promise<Environment | null> {
const requested = await getVSInstallForKit(kit);
if (!requested) {
return null;
}
return varsForVSInstallation(requested, kit.visualStudioArchitecture!, kit.preferredGenerator?.platform);
}
async function getVSInstallForKit(kit: Kit): Promise<VSInstallation | undefined> {
if (process.platform !== "win32") {
return undefined;
}
console.assert(kit.visualStudio);
console.assert(kit.visualStudioArchitecture);
const installs = await vsInstallations();
const match = (inst: VSInstallation) =>
// old Kit format
(legacyKitVSName(inst) === kit.visualStudio) ||
// new Kit format
(kitVSName(inst) === kit.visualStudio) ||
// Clang for VS kit format
(!!kit.compilers && kit.name.indexOf("Clang") >= 0 && kit.name.indexOf(vsDisplayName(inst)) >= 0);
return installs.find(match);
}
CMake Tools Diagnostics
No response
Debug Log
No response
Additional Information
No response
@SimonBoorer This is definitely something that would be nice. I will add this to our backlog. THanks.
Closing, fixed in #3775