Skip to content

Commit d56135e

Browse files
authored
Add localized MD/HTML file for guidance when incompatible VSIX (#8920)
1 parent 7216af8 commit d56135e

File tree

4 files changed

+63
-12
lines changed

4 files changed

+63
-12
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<h1 data-loc-id="incompatible.extension.heading">Incompatible or Mismatched C/C++ Extension Binaries</h1>
2+
3+
<p data-loc-id="incompat.extension.text1">The C/C++ extension includes native binaries.</p>
4+
5+
<p data-loc-id="incompat.extension.text2">When installed via the marketplace UI in VS Code, the correct native binaries should be included. If incompatible binaries were detected and the C/C++ extension had been installed via the marketplace UI in VS Code, <a href="https://github.com/microsoft/vscode/issues/new?assignees=&labels=&template=bug_report.md" data-loc-id="bug.report.link.title">please report the issue</a>.</p>
6+
7+
<h1 data-loc-id="reinstalling.extension.heading">Reinstalling the C/C++ Extension</h1>
8+
9+
<p data-loc-id="reinstall.extension.text1">When reinstalling an equivalent version of an extension, VS Code may reuse the existing extension directory. To prevent this from occurring when reinstalling the C/C++ extension, it may be necessary to first delete the existing extension directory.</p>
10+
11+
<p data-loc-id="reinstall.extension.text2">Installed extension directories can be found under one of the following paths under your user directory (`%USERPROFILE%` on Windows, or `$HOME` on Linux and macOS)</p>
12+
13+
<pre><code class="lang-bash">%USERPROFILE%\.vscode\extensions</code></pre>
14+
<pre><code class="lang-bash">%USERPROFILE%\.vscode-insiders\extensions</code></pre>
15+
<pre><code class="lang-bash">%USERPROFILE%\.vscode-exploration\extensions</code></pre>
16+
17+
<p data-loc-id="reinstall.extension.text3">In a remote connection:</p>
18+
<pre><code class="lang-bash">$HOME/.vscode-server/extensions</code></pre>
19+
<pre><code class="lang-bash">$HOME/.vscode-server-insiders/extensions</code></pre>
20+
<pre><code class="lang-bash">$HOME/.vscode-server-exploration/extensions</code></pre>
21+
22+
<p data-loc-id="reinstall.extension.text4">Example paths to installed C/C++ extension directories:</p>
23+
24+
<p data-loc-id="reinstall.extension.text5">On Windows:</p>
25+
<pre><code class="lang-bash">%USERPROFILE%\.vscode\extensions\ms-vscode.cpptools-1.9.0</code></pre>
26+
27+
<p data-loc-id="reinstall.extension.text6">On Linux:</p>
28+
<pre><code class="lang-bash">$HOME/.vscode/extensions/ms-vscode.cpptools-1.9.0</code></pre>
29+
30+
<p data-loc-id="reinstall.extension.text7">Then reinstall via the marketplace UI in VS Code.</p>
31+
32+
<p data-loc-id="reinstall.extension.text8">If the correct version of the extension fails to be deployed by VS Code, the correct VSIX for your system can be <a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools" data-loc-id="download.vsix.link.title">downloaded from the VS Code marketplace web site</a> and installed using the `Install from VSIX...` option under the '...' menu in the marketplace UI in VS Code.</p>

Extension/gulpfile.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ const https = require('https');
2626

2727
// Patterns to find HTML files
2828
const htmlFilesPatterns = [
29-
"ui/**/*.html"
29+
"ui/**/*.html",
30+
"Reinstalling the Extension.md"
3031
];
3132

3233
// HTML files for walkthroughs are handled differently, as localization support
@@ -370,11 +371,6 @@ const generateLocalizedHtmlFiles = () => {
370371
contents: Buffer.from(newContent, 'utf8')
371372
}));
372373
});
373-
// Put the original in an 'en' directory.
374-
this.queue(new vinyl({
375-
path: path.join("html/en", relativePath),
376-
contents: file.contents
377-
}));
378374
});
379375
};
380376

Extension/src/LanguageServer/extension.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ function sendActivationTelemetry(): void {
158158
}
159159

160160
async function checkVsixCompatibility(): Promise<void> {
161+
const ignoreMismatchedCompatibleVsix: PersistentState<boolean> = new PersistentState<boolean>("CPP." + util.packageJson.version + ".ignoreMismatchedCompatibleVsix", false);
162+
let resetIgnoreMismatchedCompatibleVsix: boolean = true;
163+
161164
// Check to ensure the correct platform-specific VSIX was installed.
162165
const vsixManifestPath: string = path.join(util.extensionPath, ".vsixmanifest");
163166
// Skip the check if the file does not exist, such as when debugging cpptools.
@@ -218,15 +221,33 @@ async function checkVsixCompatibility(): Promise<void> {
218221
console.log("Unrecognized TargetPlatform in .vsixmanifest");
219222
break;
220223
}
224+
const moreInfoButton: string = localize("more.info.button", "More Info");
225+
const ignoreButton: string = localize("ignore.button", "Ignore");
226+
let promise: Thenable<string | undefined> | undefined;
221227
if (!isPlatformCompatible) {
222-
vscode.window.showErrorMessage(localize("vsix.platform.incompatible", "The target platform {0} specifed in the C/C++ Extension VSIX is not compatible with your system.", vsixTargetPlatform));
228+
promise = vscode.window.showErrorMessage(localize("vsix.platform.incompatible", "The C/C++ extension installed does not match your system.", vsixTargetPlatform), moreInfoButton);
223229
} else if (!isPlatformMatching) {
224-
vscode.window.showWarningMessage(localize("vsix.platform.mismatching", "The target platform {0} specifed in the C/C++ Extension VSIX does not match VS Code.", vsixTargetPlatform));
230+
if (!ignoreMismatchedCompatibleVsix.Value) {
231+
resetIgnoreMismatchedCompatibleVsix = false;
232+
promise = vscode.window.showWarningMessage(localize("vsix.platform.mismatching", "The C/C++ extension installed is compatible with but does not match your system.", vsixTargetPlatform), moreInfoButton, ignoreButton);
233+
}
234+
}
235+
if (promise) {
236+
promise.then(async (value) => {
237+
if (value === moreInfoButton) {
238+
await vscode.commands.executeCommand("markdown.showPreview", vscode.Uri.file(util.getLocalizedHtmlPath("Reinstalling the Extension.md")));
239+
} else if (value === ignoreButton) {
240+
ignoreMismatchedCompatibleVsix.Value = true;
241+
}
242+
});
225243
}
226244
} else {
227245
console.log("Unable to find TargetPlatform in .vsixmanifest");
228246
}
229247
}
248+
if (resetIgnoreMismatchedCompatibleVsix) {
249+
ignoreMismatchedCompatibleVsix.Value = false;
250+
}
230251
}
231252

232253
/**

Extension/src/common.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,11 +1031,13 @@ export function getLocaleId(): string {
10311031

10321032
export function getLocalizedHtmlPath(originalPath: string): string {
10331033
const locale: string = getLocaleId();
1034-
const localizedFilePath: string = getExtensionFilePath(path.join("dist/html/", locale, originalPath));
1035-
if (!fs.existsSync(localizedFilePath)) {
1036-
return getExtensionFilePath(originalPath);
1034+
if (!locale.startsWith("en")) {
1035+
const localizedFilePath: string = getExtensionFilePath(path.join("dist/html/", locale, originalPath));
1036+
if (fs.existsSync(localizedFilePath)) {
1037+
return localizedFilePath;
1038+
}
10371039
}
1038-
return localizedFilePath;
1040+
return getExtensionFilePath(originalPath);
10391041
}
10401042

10411043
export interface LocalizeStringParams {

0 commit comments

Comments
 (0)