VSCode: use chrome instead of pwa-chrome? - visual-studio-code

I got the following JSON snippet from a coworker's launch.json file. He recommended as a way to debug client-side code from VS code. But when I inserted in my file, it complains, "replace pwa-chrome with chrome". Can someone explain what is going on? What choice is being made?
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
}

Related

How do I get new HTML files to execute in VS Code?

I have recently started learning WebDev using Colt Steele Udemy course. I've created few HTML files and whenever I try to execute any of them only the first created .html file opens in Chrome. How do I get the other files to open in the browser. Eg: If I create 3 files i.e a.html, b.html & c.html only a.html opens in Chrome even if b/c is open in the editor. This happens with both debugging or run without debugging. My VS Code version is 1.65.2. Please advice.
The launch.json code is:
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Open a.html",
"file": "e:\\\\Colt Steele\\HTML the essentials\\a.html"
}
The launch configuration you're showing is telling VSCode what to do when running the project. You can change the launch configuration to open a different file by default:
{
"type": "pwa-chrome",
"request": "launch",
"name": "Open b.html",
"file": "e:\\\\Colt Steele\\HTML the essentials\\b.html"
}
Or perhaps add multiple launch configurations, which you can select when debugging/running:
{
"type": "pwa-chrome",
"request": "launch",
"name": "Open a.html",
"file": "e:\\\\Colt Steele\\HTML the essentials\\a.html"
},
{
"type": "pwa-chrome",
"request": "launch",
"name": "Open b.html",
"file": "e:\\\\Colt Steele\\HTML the essentials\\b.html"
}
In general any given "application" would have a single default page as the entry point, and from there you can navigate through the application to use the other pages. So you might have a single index.html as the launch file, and in whatever you're building there would be links to other files as needed for the application.
But if what you're building for whatever reason truly has different "entry points" then you can just set up your build configurations based on that and select which configuration to use when running the application.
Alternatively (and I haven't tested this), you should be able to tell it to launch "the current file" by using a variable called file in the launch config:
{
"type": "pwa-chrome",
"request": "launch",
"name": "Open Current File",
"program": "${file}"
}

How to launch swagger url through vscode?

I am trying to launch swagger UI in browser using dotnet run command. Here is what I have tried in launch.json file. Expected outcome is that it should launch browser at the specified url and open swagger UI automatically. FYI I am using dotnet5 and created new web api project that already has swagger baked in. It doesn't launch the browser.
If you are using dotnet run command then its a known limitation that it doesn't launch a browser.
Please refer to this link for confirmation
While it doesn't launch it, it will still have your project running just means you manually have to type it in browser or use one of the workarounds listed in that issue.
Use compounds launch settings
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/WebApi/bin/Debug/net7.0/YourWebDll.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": "Launch Chrome",
"request": "launch",
"type": "chrome",
"url": "https://localhost:5001/swagger/index.html",
"webRoot": "${workspaceFolder}"
}
],
"compounds": [
{
"name": ".Net Core & Chrome",
"configurations": [".NET Core Launch (console)","Launch Chrome"]
}
]
This will run your app and launch chrome at the URL you want.

Run and Debug problems in Visual Studio Code using haxe

I'm currently coding in Haxe with Heaps using Visual Studio Code. The latter has recently updated to version 1.56 which is now giving my a strange problem I can't manage to fix. Before the update, I was able to click Run and Debug using Hashlink in order to open the window of my game. After the update, when I Run and Debug it no longer opens the window, despite the compile.hxml and launch.json being exactly the same as before:
compile.hxml:
-cp src
-lib heaps
-lib hlsdl
-hl main.hl
-main Main
.json
"version": "0.2.0",
"configurations": [
{
"name": "HashLink (launch)",
"request": "launch",
"type": "hl",
"cwd": "${workspaceFolder}",
"preLaunchTask": {
"type": "haxe",
"args": "active configuration"
}
},
{
"name": "HashLink (attach)",
"request": "attach",
"port": 6112,
"type": "hl",
"cwd": "${workspaceFolder}",
"preLaunchTask": {
"type": "haxe",
"args": "active configuration"
}
}
]
Is anyone experiencing a similar problem?
Update: hashlink-debugger 1.1.2 was released, which should fix the problem.
It's a known issue:
HL debugger no longer works in latest vscode #97
You can downgrade to the previous VSCode release or subscribe to the issue and wait for the hashlink-debugger update.

How do I switch language in Visual Studio Code?

I am playing with a few programming languages within Visual Studio Code. My initial language is Python, and then I added Go in there within their own respective folders. When I run the Go file, it tries to interpret with Python, which obviously would fail.
Could I have different languages within the same project and separate them by different interpreter?
How do I point one folder to run with Python, the other to run with Go?
Thanks.
I've gotten it to work. The Configuration settings control what you are building. It is set within the launch.json file, and you can have different languages with the same project and run them in different interpreter/compiler.
This is what I have in my launch.json.
"version": "0.2.0",
"configurations": [
{
"name": "GO: Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {},
"args": []
},
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]

Can not change debug environment automatically on visual studio code with config

For example, my root workstation directory is /home/chain/Project. And I have two separate projects which is python and website. My launch.json goes:
{
"version": "0.2.0",
"configurations":
[
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${workspaceRoot}/python_project_source/test.py",
"cwd": "${workspaceRoot}/python_project_source",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "${workspaceRoot}/website/test.html",
"webRoot": "${workspaceRoot}/website"
}
]
}
As expected when I select test.py and press 'F5' it can switch to python debug environment, and when I select test.html the Chrome will be opened.
The fact is, VS code only remember the environment I debugged last time rather than change it automatically. So the only thing I do now is adding some comments to one environment (/* */) when I need to compile the other.:(
Is there something wrong in my launch.json?
Automatically switching the debug environment based on the file (or file-type) is not a current feature of Visual Studio Code, I believe.
You'll have to manually switch the launch configuration depending on the type of debugging task you want to perform.
And, of course, you could consider writing a feature request: https://github.com/Microsoft/vscode