@@ -78,7 +78,6 @@ export async function requestProjectInformation(server: OmniSharpServer, request
7878export async function requestWorkspaceInformation ( server : OmniSharpServer ) {
7979 const response = await server . makeRequest < protocol . WorkspaceInformationResponse > ( protocol . Requests . Projects ) ;
8080 if ( response . MsBuild && response . MsBuild . Projects ) {
81- const blazorDetectionEnabled = hasBlazorWebAssemblyDebugPrerequisites ( ) ;
8281 let blazorWebAssemblyProjectFound = false ;
8382
8483 for ( const project of response . MsBuild . Projects ) {
@@ -87,28 +86,17 @@ export async function requestWorkspaceInformation(server: OmniSharpServer) {
8786 const isProjectBlazorWebAssemblyProject = await isBlazorWebAssemblyProject ( project ) ;
8887 const isProjectBlazorWebAssemblyHosted = isBlazorWebAssemblyHosted ( project , isProjectBlazorWebAssemblyProject ) ;
8988
90- project . IsBlazorWebAssemblyHosted = blazorDetectionEnabled && isProjectBlazorWebAssemblyHosted ;
91- project . IsBlazorWebAssemblyStandalone = blazorDetectionEnabled && isProjectBlazorWebAssemblyProject && ! project . IsBlazorWebAssemblyHosted ;
89+ project . IsBlazorWebAssemblyHosted = isProjectBlazorWebAssemblyHosted ;
90+ project . IsBlazorWebAssemblyStandalone = isProjectBlazorWebAssemblyProject && ! project . IsBlazorWebAssemblyHosted ;
9291
9392 blazorWebAssemblyProjectFound = blazorWebAssemblyProjectFound || isProjectBlazorWebAssemblyProject ;
9493 }
9594
96- const configuration = vscode . workspace . getConfiguration ( 'razor' ) ;
97- const disableBlazorDebugPrompt = configuration . get ( 'disableBlazorDebugPrompt' ) ;
98-
99- if ( ! blazorDetectionEnabled && blazorWebAssemblyProjectFound && ! disableBlazorDebugPrompt ) {
95+ if ( blazorWebAssemblyProjectFound && ! hasBlazorWebAssemblyDebugPrerequisites ( server ) ) {
96+ const configuration = vscode . workspace . getConfiguration ( 'razor' ) ;
10097 // There's a Blazor Web Assembly project but VSCode isn't configured to debug the WASM code, show a notification
10198 // to help the user configure their VSCode appropriately.
102- vscode . window . showInformationMessage ( 'Additional setup is required to debug Blazor WebAssembly applications.' , 'Don\'t Ask Again' , 'Learn more' , 'Close' )
103- . then ( async result => {
104- if ( result === 'Learn more' ) {
105- const uriToOpen = vscode . Uri . parse ( 'https://aka.ms/blazordebugging#vscode' ) ;
106- await vscode . commands . executeCommand ( 'vscode.open' , uriToOpen ) ;
107- }
108- if ( result === 'Don\'t Ask Again' ) {
109- await configuration . update ( 'disableBlazorDebugPrompt' , true ) ;
110- }
111- } ) ;
99+ showBlazorConfigurationRequiredPrompt ( server , configuration ) ;
112100 }
113101 }
114102
@@ -239,17 +227,10 @@ async function isBlazorWebAssemblyProject(project: MSBuildProject): Promise<bool
239227 return false ;
240228}
241229
242- function hasBlazorWebAssemblyDebugPrerequisites ( ) {
230+ function hasBlazorWebAssemblyDebugPrerequisites ( server : OmniSharpServer ) {
243231 const companionExtension = vscode . extensions . getExtension ( 'ms-dotnettools.blazorwasm-companion' ) ;
244232 if ( ! companionExtension ) {
245- const msg = 'The Blazor WASM Debugging Extension is required to debug Blazor WASM apps in VS Code.' ;
246- vscode . window . showInformationMessage ( msg , 'Install Extension' , 'Close' )
247- . then ( async result => {
248- if ( result === 'Install Extension' ) {
249- const uriToOpen = vscode . Uri . parse ( 'vscode:extension/ms-dotnettools.blazorwasm-companion' ) ;
250- await vscode . commands . executeCommand ( 'vscode.open' , uriToOpen ) ;
251- }
252- } ) ;
233+ showBlazorDebuggingExtensionPrompt ( server ) ;
253234 return false ;
254235 }
255236
@@ -282,3 +263,39 @@ function isWebProject(project: MSBuildProject): boolean {
282263 // TODO: Have OmniSharp provide the list of SDKs used by a project and check that list instead.
283264 return projectFileText . toLowerCase ( ) . indexOf ( 'sdk="microsoft.net.sdk.web"' ) >= 0 ;
284265}
266+
267+ function showBlazorConfigurationRequiredPrompt ( server : OmniSharpServer , configuration : vscode . WorkspaceConfiguration ) {
268+ const disableBlazorDebugPrompt = configuration . get ( 'disableBlazorDebugPrompt' ) ;
269+
270+ const promptShownKey = 'blazor_configuration_required_prompt_shown' ;
271+ if ( ! disableBlazorDebugPrompt && ! server . sessionProperties [ promptShownKey ] ) {
272+ server . sessionProperties [ promptShownKey ] = true ;
273+
274+ vscode . window . showInformationMessage ( 'Additional setup is required to debug Blazor WebAssembly applications.' , 'Don\'t Ask Again' , 'Learn more' , 'Close' )
275+ . then ( async result => {
276+ if ( result === 'Learn more' ) {
277+ const uriToOpen = vscode . Uri . parse ( 'https://aka.ms/blazordebugging#vscode' ) ;
278+ await vscode . commands . executeCommand ( 'vscode.open' , uriToOpen ) ;
279+ }
280+ if ( result === 'Don\'t Ask Again' ) {
281+ await configuration . update ( 'disableBlazorDebugPrompt' , true ) ;
282+ }
283+ } ) ;
284+ }
285+ }
286+
287+ function showBlazorDebuggingExtensionPrompt ( server : OmniSharpServer ) {
288+ const promptShownKey = 'blazor_debugging_extension_prompt_shown' ;
289+ if ( ! server . sessionProperties [ promptShownKey ] ) {
290+ server . sessionProperties [ promptShownKey ] = true ;
291+
292+ const msg = 'The Blazor WASM Debugging Extension is required to debug Blazor WASM apps in VS Code.' ;
293+ vscode . window . showInformationMessage ( msg , 'Install Extension' , 'Close' )
294+ . then ( async result => {
295+ if ( result === 'Install Extension' ) {
296+ const uriToOpen = vscode . Uri . parse ( 'vscode:extension/ms-dotnettools.blazorwasm-companion' ) ;
297+ await vscode . commands . executeCommand ( 'vscode.open' , uriToOpen ) ;
298+ }
299+ } ) ;
300+ }
301+ }
0 commit comments