Skip to content

Commit fdc949b

Browse files
committed
Extended VC++ Dep check to include version and also check after updates
Change-Id: Ia8c4185de5f594a7dee6e941a7087e58a8688b68
1 parent f1b5b1d commit fdc949b

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

gui/extension/src/WebviewProviders/WelcomeWebviewProvider.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ const getWelcomeWebviewContent = (rootPath: Uri, showVCRuntimePrompt: boolean):
408408
nextBtn.value = "Next >";
409409
currentPage = vcRuntimePage + 1;
410410
} else {
411-
const errorMessage = "VC++ runtime library installation not detected.";
411+
const errorMessage = "VC++ runtime library installation not detected or it is too old.";
412412
document.getElementById("checkError").innerHTML = errorMessage;
413413
414414
showPage(vcRuntimePage);
@@ -454,7 +454,7 @@ const getWelcomeWebviewContent = (rootPath: Uri, showVCRuntimePrompt: boolean):
454454
*
455455
* @returns true, if the VC++ runtimes are installed, otherwise false
456456
*/
457-
const checkVcRuntime = (): Promise<boolean> => {
457+
export const checkVcRuntime = (): Promise<boolean> => {
458458
return new Promise((resolve, reject) => {
459459
if (platform() === "win32") {
460460
// cSpell:ignore HKLM Runtimes promisified
@@ -467,8 +467,20 @@ const checkVcRuntime = (): Promise<boolean> => {
467467
for (const key in items) {
468468
const item = items[key];
469469
if (item.exists) {
470-
cRuntimeInstalled = true;
471-
break;
470+
if ("Version" in item.values) {
471+
const versionStr = item.values.Version.value.toString();
472+
if (versionStr.length > 6) {
473+
try {
474+
const version = parseFloat(versionStr.substring(1, 6));
475+
if (version >= 14.38) {
476+
cRuntimeInstalled = true;
477+
break;
478+
}
479+
} catch {
480+
// Ignore
481+
}
482+
}
483+
}
472484
}
473485
}
474486

gui/extension/src/extension.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141

4242
import { ExtensionHost } from "./ExtensionHost.js";
4343
import { webSession } from "../../frontend/src/supplement/WebSession.js";
44-
import { setupInitialWelcomeWebview } from "./WebviewProviders/WelcomeWebviewProvider.js";
44+
import { checkVcRuntime, setupInitialWelcomeWebview } from "./WebviewProviders/WelcomeWebviewProvider.js";
4545
import { waitFor } from "../../frontend/src/utilities/helpers.js";
4646
import { MessageScheduler } from "../../frontend/src/communication/MessageScheduler.js";
4747

@@ -288,9 +288,10 @@ export const activate = (context: ExtensionContext): void => {
288288
const lastRunVersion = context.globalState.get("MySQLShellLastRunVersion");
289289
if (!lastRunVersion || lastRunVersion === "" || lastRunVersion !== currentVersion) {
290290
void context.globalState.update("MySQLShellLastRunVersion", currentVersion);
291+
const osName = platform();
291292

292293
// Reset extended attributes on macOS
293-
if (platform() === "darwin") {
294+
if (osName === "darwin") {
294295
const shellDir = join(context.extensionPath, "shell");
295296
if (existsSync(shellDir)) {
296297
// cSpell:ignore xattr
@@ -301,6 +302,29 @@ export const activate = (context: ExtensionContext): void => {
301302
// cSpell:ignore xattr
302303
void childProcess.execSync(`xattr -rc ${routerDir}`);
303304
}
305+
} else if (osName === "win32") {
306+
const promptForVcUpdate = () => {
307+
// cSpell:ignore redist msvc
308+
void window.showErrorMessage(
309+
"The Microsoft Visual C++ Redistributable needs to be updated and VS Code needs to be " +
310+
"restarted. Do you want to open the Microsoft download page?",
311+
"Open Download Page", "Cancel").then((answer) => {
312+
if (answer !== "Cancel") {
313+
void env.openExternal(Uri.parse(
314+
"https://learn.microsoft.com/en-us/cpp/windows/" +
315+
"latest-supported-vc-redist?view=msvc-170"));
316+
}
317+
});
318+
};
319+
320+
checkVcRuntime().then((result: boolean) => {
321+
if (!result) {
322+
promptForVcUpdate();
323+
}
324+
}).catch((reason) => {
325+
printChannelOutput(String(reason), true);
326+
promptForVcUpdate();
327+
});
304328
}
305329
}
306330

0 commit comments

Comments
 (0)