Debugging Blazor WASM in VS Code fails because of Unbound breakpoint - visual-studio-code

I have just created a new Blazor WASM and I have followed the below resource to enable debugging in VS Code
https://learn.microsoft.com/en-us/aspnet/core/blazor/debug?view=aspnetcore-6.0&tabs=visual-studio-code
And as per it, I put a breakpoint on the currentCount++ line, but on debugging it does not hit because the breakpoint is unbound.
The dotnet version is 6
Launch Settings:
"profiles": {
"TestVSCodeDebug": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:7240;http://localhost:5053",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
Launch.json :
"version": "0.2.0",
"configurations": [
{
"type": "blazorwasm",
"name": "Launch and Debug BlazorWASM",
"request": "launch",
"url": "https://localhost:7240"
}
]
Above is orginal.Below updated on 24th-Jan-2022:
The breakpoint hits in VS 2022 Preview

This workaround got VSCode breakpoints to hit for me
Changing my launch.json to :
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Debug Blazor Web Assembly in Chrome",
"type": "blazorwasm",
"request": "launch",
"timeout": 30000,
"url": "http://localhost:5000",
"webRoot": "${workspaceFolder}",
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
}]
}
Also make sure you're launching with http and not https.
Install and debug with chrome :( Can't get it to work on FF.
More info here :
https://github.com/dotnet/aspnetcore/issues/20597

Related

White window when debugging Electron forge "typescript + webpack" app from VSCode - MAIN_WINDOW_WEBPACK_ENTRY variable is not being set

I created an Electron forge project as described in the forge guide using the "typescript + webpack" template:
> yarn create electron-app debugging-test --template=typescript-webpack
The generated app works fine when running npm start. Then I wanted to configure VSCode debugger for this template so I followed the debugging section of the forge guide and created launch.json file with this content:
{
"type": "node",
"request": "launch",
"name": "Electron Main",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron-forge-vscode-nix",
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron-forge-vscode-win.cmd"
},
// runtimeArgs will be passed directly to your Electron application
"runtimeArgs": [
"foo",
"bar"
],
"cwd": "${workspaceFolder}"
}
This does not really work for me. After clicking F5 the debugger starts but it doesn't break on any breakpoints in the main process nor no window appears. Then I tried the launch.json from Microsoft's vscode-recipes:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Electron: Main",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"runtimeArgs": [
"--remote-debugging-port=9223",
"."
],
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
}
},
{
"name": "Electron: Renderer",
"type": "chrome",
"request": "attach",
"port": 9223,
"webRoot": "${workspaceFolder}",
"timeout": 30000
}
],
"compounds": [
{
"name": "Electron: All",
"configurations": [
"Electron: Main",
"Electron: Renderer"
]
}
]
}
This one, after hitting F5, starts the Electron window fine and even breakpoints in the main process are hit but no content is loaded to the window. The window is white. When breaking on line 21 in index.ts:
mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
I see that the MAIN_WINDOW_WEBPACK_ENTRY variable is not set and that's why there is no content loaded to the window.
What's the correct VSCode setup to debug "typescript + webpack" electron's forge template?
I found this is a bug in Windows that is tracked here on Github. The workaround is to remove the fork-ts-checker-webpack-plugin. E.g., in webpack.plugins.js remove the new ForkTsCheckerWebpackPlugin() from the array for now until it is fixed:
//const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
module.exports = [/*new ForkTsCheckerWebpackPlugin()*/];
After that debugging both, main and renderer, processes work great!

VS Code console.log() appears in developer tools instead of debug console

I've been working on a VS Code extension using the Hello World example generated by Yeoman (yo code). The console.log() message only shows up in the Developer Tools, but not in the Debug Console like all of the VS Code documentation suggests. Here is my launch.json (it is unchanged from what yo code generated:
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}",
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
I've tried adding "console": "internalConsole", "debugOptions": ["RedirectOutput"], and "outputCapture": "std" as suggested in various other answers on Stack Overflow, but A) none of those work and B) they give an error in launch.json that Property <property> is not allowed.
I'm launching using F5 (run with debugging). Breakpoints do work, logpoints don't log anything to Debug Console either.
What am I missing?

How to run flutter in chrome with args in VS Code

How can I run my flutter app in chrome with args?
I want to run/debug/attach my flutter app in a chrome session with --disable-web-security.
In the end I would expect to have a single launch configuration that does launch my app in a single chrome session (similar to flutter run -d chrome).
In the launch.json, I did play around with attach/launch, compounds, tasks but could not make it work.
{
"version": "0.2.0",
"compounds": [
{
"name": "Launch D1",
"configurations": [
"Launch Chrome",
"app1"
],
}
],
"configurations": [
{
"name": "Launch Chrome",
"request": "launch",
"type": "chrome",
"webRoot": "${workspaceFolder}/app1",
"runtimeArgs": [
"--disable-web-security",
"--user-data-dir=%APPDATA%\\..\\Local\\tempc"
],
},
{
"name": "app1",
"cwd": "app1",
"request": "launch",
"type": "dart",
"deviceId": "chrome"
}
]
}
If you're having certificate issues running on web, you can disable the warnings using "runtimeArgs": ["--ignore-certificate-errors"]
You can also follow other workarounds mentioned on this GitHub issue thread.

How to debug angular application using Visual Studio Code + VSCode remote + Chrome debugger

We have an angular application (angular 8), the code is set up on an Ubuntu vm.
and using Visual Studio Code + Remote Development Tool (Microsoft) for development.
While development is working fine I am facing issues while debugging the app.
launch.json configuration
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"url": "http://localhost:4200/#",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"runtimeArgs": ["--disable-session-crashed-bubble"]
},
{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"port": 9222,
"address": "localhost",
"webRoot": "${workspaceFolder}",
"sourceMaps": true
}
]
}
vscode command used for port forwarding : "Forward Port From Active Host"
angular.json config for dev env
{
"dev": {
"optimization": false,
"outputHashing": "all",
"sourceMap": true,
"extractCss": true,
"namedChunks": true,
"aot": true,
"extractLicenses": true,
"vendorChunk": true,
"buildOptimizer": false,
"fileReplacements": [
{
"replace": "ui/environments/environment.ts",
"with": "ui/environments/environment.ts"
}
]
}
}
with this I am able to connect to the remote from local, however, the "Attach to Chrome" is not able to find the files and producing errors like
Unable to open 'dashboard.man~de6ca691.77f46380879a4a0699b4.js': Unable to read file (Error: File not found
(vscode-remote://ssh-remote+angular_serve/kite/angular_proj/dashboard/dashboard.man~de6ca691.77f46380879a4a0699b4.js)).
Is remote debugging like this is possible?
Am I missing any configurations?
To debug angular code follow these steps:-
Option 1 Using VS-code
https://scotch.io/tutorials/debugging-angular-cli-applications-in-visual-studio-code
OR
Option 2 You can directly use the chrome.
ctrl+shift+I and go to the source tab
ctrl+p you will get the list of files. choose your file for ex.
app.component.ts
Now you can see your code and use the sidebar you have line numbers
to select debug points.

Combining two launch.json configurations to run sequentially in Visual Studio Code

As part of a .NET Core 2.0 project I'm starting up a .dll then launching Chrome to debug the front end via the Debugger for Chrome extension.
If I launch both manually as such:
{
"name": "[Development] Launch Server",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/bin/Debug/netcoreapp2.0/Website.dll",
"args": [],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"env": {
"ASPNETCORE_ENVIRONMENT": "LocalDevelopment"
},
"sourceFileMap": {
"/Views": "${workspaceRoot}/Views"
}
}
and then
{
"name": "[Development] Debug Browser",
"type": "chrome",
"request": "launch",
"url": "http://localhost:5000/home",
"port": 9222,
"webRoot": "${workspaceRoot}",
"sourceMapPathOverrides": {
"webpack:///./*": "${workspaceRoot}\\*"
}
}
everything works great. However, this is a slow process because the 'Launch Server' configuration takes a few minutes to build/release and then I must manually launch 'Debug Browser'.
Ideally I would have a 'one click' solution that handles the first configuration and upon release starts up the second configuration.
I have tried:
"compounds": [
{
"name": "[Development] Launch Server & Debug Browser",
"configurations": [
"[Development] Launch Server",
"[Development] Debug Browser"
]
}
]
but this just ends up launching the first configuration and receiving this error
while the second configuration seemingly never firing off. I've looked into tasks.json but I'm not sure that's the right place for what I'm trying to accomplish.
How can I turn this into a fire and forget?