Skip to content

Commit 4ee2699

Browse files
authored
Fix Razor browser discovery issues on Mac and Linux (#6269)
1 parent 1838070 commit 4ee2699

File tree

4 files changed

+190
-40
lines changed

4 files changed

+190
-40
lines changed

l10n/bundle.l10n.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"There was an unexpected error while launching your debugging session. Check the console for helpful logs and visit the debugging docs for more info.": "There was an unexpected error while launching your debugging session. Check the console for helpful logs and visit the debugging docs for more info.",
118118
"View Debug Docs": "View Debug Docs",
119119
"Ignore": "Ignore",
120-
"Run and Debug: A valid browser is not installed": "Run and Debug: A valid browser is not installed",
120+
"Run and Debug: A valid browser is not installed. Please install Edge or Chrome.": "Run and Debug: A valid browser is not installed. Please install Edge or Chrome.",
121121
"dotnet.server.useOmnisharp option has changed. Please reload the window to apply the change": "dotnet.server.useOmnisharp option has changed. Please reload the window to apply the change",
122122
"Reload Window": "Reload Window",
123123
"C# configuration has changed. Would you like to relaunch the Language Server with your changes?": "C# configuration has changed. Would you like to relaunch the Language Server with your changes?",
@@ -152,4 +152,4 @@
152152
"Disable message in settings": "Disable message in settings",
153153
"Help": "Help",
154154
"The C# extension is still downloading packages. Please see progress in the output window below.": "The C# extension is still downloading packages. Please see progress in the output window below."
155-
}
155+
}

package-lock.json

+167-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@
8383
"@types/cross-spawn": "6.0.2",
8484
"@vscode/debugprotocol": "1.56.0",
8585
"@vscode/extension-telemetry": "0.6.2",
86+
"@vscode/js-debug-browsers": "^1.1.0",
8687
"async-file": "2.0.2",
8788
"cross-spawn": "6.0.5",
89+
"execa": "4.0.0",
8890
"fs-extra": "9.1.0",
8991
"http-proxy-agent": "4.0.1",
9092
"https-proxy-agent": "5.0.0",
@@ -102,7 +104,6 @@
102104
"tmp": "0.0.33",
103105
"uuid": "^9.0.0",
104106
"vscode-html-languageservice": "^5.0.1",
105-
"vscode-js-debug-browsers": "^1.0.5",
106107
"vscode-jsonrpc": "8.2.0-next.0",
107108
"vscode-languageclient": "8.2.0-next.1",
108109
"vscode-languageserver-protocol": "3.17.4-next.1",

src/razor/src/blazorDebug/blazorDebugConfigurationProvider.ts

+19-13
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import execa = require('execa');
67
import { promises, readFileSync } from 'fs';
78
import { join } from 'path';
89
import { fileURLToPath } from 'url';
910
import * as vscode from 'vscode';
10-
import { ChromeBrowserFinder, EdgeBrowserFinder } from 'vscode-js-debug-browsers';
11+
import { ChromeBrowserFinder, EdgeBrowserFinder } from '@vscode/js-debug-browsers';
1112
import { RazorLogger } from '../razorLogger';
1213
import { JS_DEBUG_NAME, SERVER_APP_NAME } from './constants';
1314
import { onDidTerminateDebugSession } from './terminateDebugHandler';
@@ -180,28 +181,33 @@ export class BlazorDebugConfigurationProvider implements vscode.DebugConfigurati
180181

181182
public static async determineBrowserType(): Promise<string | undefined> {
182183
// There was no browser specified by the user, so we will do some auto-detection to find a browser,
183-
// favoring chrome if multiple valid options are installed.
184-
const chromeBrowserFinder = new ChromeBrowserFinder(process.env, promises, null);
185-
const chromeInstallations = await chromeBrowserFinder.findAll();
186-
if (chromeInstallations.length > 0) {
184+
// favoring Edge if multiple valid options are installed.
185+
const edgeBrowserFinder = new EdgeBrowserFinder(process.env, promises, execa);
186+
const edgeInstallations = await edgeBrowserFinder.findAll();
187+
if (edgeInstallations.length > 0) {
187188
showInformationMessage(
188189
vscode,
189-
BlazorDebugConfigurationProvider.autoDetectUserNotice.replace('{0}', `'Chrome'`)
190+
BlazorDebugConfigurationProvider.autoDetectUserNotice.replace('{0}', `'Edge'`)
190191
);
191-
return BlazorDebugConfigurationProvider.chromeBrowserType;
192+
193+
return BlazorDebugConfigurationProvider.edgeBrowserType;
192194
}
193195

194-
const edgeBrowserFinder = new EdgeBrowserFinder(process.env, promises, null);
195-
const edgeInstallations = await edgeBrowserFinder.findAll();
196-
if (edgeInstallations.length > 0) {
196+
const chromeBrowserFinder = new ChromeBrowserFinder(process.env, promises, execa);
197+
const chromeInstallations = await chromeBrowserFinder.findAll();
198+
if (chromeInstallations.length > 0) {
197199
showInformationMessage(
198200
vscode,
199-
BlazorDebugConfigurationProvider.autoDetectUserNotice.replace('{0}', `'Edge'`)
201+
BlazorDebugConfigurationProvider.autoDetectUserNotice.replace('{0}', `'Chrome'`)
200202
);
201-
return BlazorDebugConfigurationProvider.edgeBrowserType;
203+
204+
return BlazorDebugConfigurationProvider.chromeBrowserType;
202205
}
203206

204-
showErrorMessage(vscode, vscode.l10n.t('Run and Debug: A valid browser is not installed'));
207+
showErrorMessage(
208+
vscode,
209+
vscode.l10n.t('Run and Debug: A valid browser is not installed. Please install Edge or Chrome.')
210+
);
205211
return undefined;
206212
}
207213
}

0 commit comments

Comments
 (0)