'${fileDirname}' can not be resolved. Please open an editor
[Open launch.json] [Cancel]
I m getting this error whenever I try to debug my program in VSCode.
I checked my launch.json file, everything seems fine.
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
Related
launch.json:
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "msedge",
"request": "launch",
"preLaunchTask": "build",
"cwd": "${workspaceFolder}",
"webRoot": "${workspaceFolder}",
// "serverReadyAction": {
// "action": "openExternally",
// "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
// },
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://localhost:5000"
},
"sourceMaps": true,
//"url": "http://localhost:5000",
// If you have changed the default port / launch URL make sure to update the expectation below
//"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
and tasks.json:
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "process",
"command": "dotnet",
//"group": "build",
"args": [
"watch",
"run",
"${workspaceFolder}/BlazorStore9.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
// "presentation": {
// // Reveal the output only if unrecognized errors occur.
// "reveal": "silent"
// },
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile",
"options": {"cwd": "${workspaceFolder}"}
}
]
This only launches site for browsing but not debug, How to correct these files for debug?
I removed "request": "launch", from launch.json and debug works.
I found an old question related to debugging a cake script in vscode.
How do I debug a "frosting" project?
I added this to .vscode/launch.json, but it runs the project without stopping at breakpoints:
{
"name": "cake",
"type": "coreclr",
"request": "launch",
"cwd": "${workspaceFolder}/build",
"program": "dotnet",
"args": [ "run" ],
"stopAtEntry": false
}
One must run the frosting console programme (Build.dll).
.vscode/tasks.json:
{
"label": "build-cake",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/build/Build.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
.vscode/launch.json
{
"name": "cake",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-cake",
"cwd": "${workspaceFolder}/build",
"program": "${workspaceFolder}/build/bin/Debug/net6.0/Build.dll",
"args": [],
"console": "internalConsole",
"stopAtEntry": false
}
I'm confused when debugging my c++ program with vscode on Windows. I enabled "externalConsole" in "launch.json" but sometimes it did not launch the external terminal. Just a few times before it worked fine and I could input. But now it says it's running with nothing pops out and I find nowhere to input. It just gets stuck there. Are there any ways to solve this?
screenshot.png
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe 生成活动文件"
}
]
}
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe 生成活动文件",
"command": "C:\\MinGW\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:\\MinGW\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "编译器: C:\\MinGW\\bin\\g++.exe"
}
]
}
I have a folder called cmd.
When I want to run my program, I need to run the command.
go run cmd/*.go server where server is an argument.
But I don't know how to setup the debugging for my program in VsCode.
I have tried these configurations but none of these works.
{
"name": "Launch Package Test",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "cmd/main.go cmd/initialize.go cmd/commands.go cmd/pubsub_action.go", // all go files in the cmd directory
"cwd": "${workspace}",
"args": [
"server"
]
}
{
"name": "Launch Package Test",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "cmd/*go",
"cwd": "${workspace}",
"args": [
"server"
]
}
{
"name": "Launch Package Test",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "cmd/*",
"cwd": "${workspace}",
"args": [
"server"
]
}
The question is, what is the correct way to run debugging for my application?
Found the solution.
{
"name": "Launch Package Test",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "cmd",
"cwd": "${workspace}",
"args": [
"server"
]
}
Set the program to cmd
How to compile typescript code to a different folder while still being able to debug the code?
Assume I want to set a breakpoint on the first console.log in file myapp.ts:
class HelloTS {
public static main(): number {
console.log('Hello TS');
console.log("about to exit now")
return 0;
}
}
HelloTS.main();
and the following tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true
}
}
Breakpointing works fine as long as myapp.ts, myapp.js, and myapp.js.map are in the same folder.
However, when I create separate folder for sources (src/) and output (dist/), breakpointing does not work and does not throw any error either.
I have the following config, which compiles successfully, but fails to provide debugging.
.vscode/tasks.json:
{
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"args": [
"-p", ".",
"--rootDir", "src/",
"--outDir", "dist/"
],
"showOutput": "silent",
"echoCommand": true,
"problemMatcher": "$tsc"
}
.vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/src/myapp.ts",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"console": "internalConsole",
"sourceMaps": true,
"outFiles": [
"**/*.js",
"**/*.js.map"
]
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": true,
"outFiles": [],
"localRoot": "${workspaceRoot}",
"remoteRoot": null
},
{
"name": "Attach to Process",
"type": "node",
"request": "attach",
"processId": "${command.PickProcess}",
"port": 5858,
"sourceMaps": true,
"outFiles": []
}
]
}
I think the outFiles attribute in your launch.json should be:
{
...
"outFiles": [ "${workspaceRoot}/dist/**/*" ]
...
},