-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for one-step debugging for Blazor
- Loading branch information
1 parent
793fcc8
commit e0bf1f0
Showing
5 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/Razor/src/Microsoft.AspNetCore.Razor.VSCode/src/BlazorDebugConfigurationProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
|
||
import * as vscode from 'vscode'; | ||
|
||
import { RazorLogger } from './RazorLogger'; | ||
|
||
export class BlazorDebugConfigurationProvider implements vscode.DebugConfigurationProvider { | ||
private logger: RazorLogger; | ||
private vscodeType: typeof vscode; | ||
|
||
constructor(logger: RazorLogger, vscodeType: typeof vscode) { | ||
this.logger = logger; | ||
this.vscodeType = vscodeType; | ||
} | ||
|
||
public resolveDebugConfiguration(folder: vscode.WorkspaceFolder | undefined, configuration: vscode.DebugConfiguration): vscode.ProviderResult<vscode.DebugConfiguration> { | ||
const app = { | ||
name: '.NET Core Launch (Blazor Standalone)', | ||
type: 'coreclr', | ||
request: 'launch', | ||
program: 'dotnet', | ||
args: ['run'], | ||
cwd: '${workspaceFolder}', | ||
env: { | ||
ASPNETCORE_ENVIRONMENT: 'Development', | ||
...configuration.env, | ||
}, | ||
}; | ||
const browser = { | ||
name: '.NET Core Debug Blazor Web Assembly in Browser', | ||
type: configuration.browser === 'edge' ? 'edge' : 'pwa-chrome', | ||
request: 'launch', | ||
timeout: 30000, | ||
url: configuration.url || 'https://localhost:5001', | ||
webRoot: '${workspaceFolder}', | ||
inspectUri: '{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}', | ||
}; | ||
|
||
this.vscodeType.debug.startDebugging(folder, app).then( | ||
appStartFulfilled => { | ||
if (appStartFulfilled) { | ||
this.vscodeType.debug.startDebugging(folder, browser).then( | ||
debugStartFulfilled => { | ||
if (debugStartFulfilled) { | ||
this.logger.logVerbose('Launching JavaScript debugger...'); | ||
} | ||
}, | ||
error => { | ||
this.logger.logError('Error when launching Chrome debugger: ', error); | ||
}, | ||
); | ||
} | ||
}, | ||
error => { | ||
this.logger.logError('Error when launching application: ', error); | ||
}, | ||
); | ||
|
||
return undefined; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters