Couldn't find 'project.json' in current directory - .NET Core Webapp debugging
Solution 1
I needed to add this code
tasks.json
"options":{
"cwd": "${workspaceRoot}/Core"
}
Solution 2
None of the answers helped me. I just specified the whole path to project.json and it began to work fine.
tasks.json
{
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [
"${workspaceRoot}\\project.json"
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]}
So, for this particular question it would be
"args": [
"${workspaceRoot}\\Core\\project.json"
],
Rovdjuret
Love coffee and clean code, open mind on improving my programming skill set.
Updated on June 05, 2022Comments
-
Rovdjuret almost 2 years
I'm trying to setup debugging on OSX environment using .NET Core RC2 and Visual Studio Code. The following error is given when trying to run the debugger.
Couldn't find 'project.json' in current directory
Currently I've setup launch.json (see below) and chosen .NET Core Launch (web) in Visual Studio Code. As my project is in a folder called Core and sharing space with two other folders my structure looks like this.
Structure
--.vscode
------ launch.json
------ tasks.json-- Core
-- Core.Data
-- Core.Service
launch.json
{ "version": "0.2.0", "configurations": [ { "name": ".NET Core Launch (console)", "type": "coreclr", "request": "launch", "preLaunchTask": "build", "program": "${workspaceRoot}/Core/bin/Debug/netcoreapp1.0/Core.dll", "args": [], "cwd": "${workspaceRoot}/Core", "stopAtEntry": false }, { "name": ".NET Core Launch (web)", "type": "coreclr", "request": "launch", "preLaunchTask": "build", "program": "${workspaceRoot}/Core/bin/Debug/netcoreapp1.0/Core.dll", "args": [], "cwd": "${workspaceRoot}/Core", "stopAtEntry": false, "launchBrowser": { "enabled": true, "args": "${auto-detect-url}", "windows": { "command": "cmd.exe", "args": "/C start ${auto-detect-url}" }, "osx": { "command": "open", "args": "-a chrome ${auto-detect-url}" }, "linux": { "command": "xdg-open" } } }, { "name": ".NET Core Attach", "type": "coreclr", "request": "attach", "processName": "<example>" } ] }
Folder structure
-
lmo almost 8 yearsThis answer turned up in the low quality review queue, presumably because you don't provide any explanation of the code. If this code answers the question, consider adding adding some text explaining the code in your answer. This way, you are far more likely to get more upvotes — and help the questioner learn something new.
-
Kizmar almost 8 yearsThis fixed my issue too. I wanted to be able to open the root solution folder and have it run WebApi. Adding the options mentioned above in the root of the tasks.json tells Code to run from the WebApi and use it's project.json.
-
adglopez almost 8 yearsthis worked for me too. This indicates the current working directory of the executed command or script (as the vscode shows) and defaults to ${workspaceRoot}. I'm not sure how the marked solution worked for other people, because without this value setup properly the project was not even building.