VS Code asp.net core debug fail

I'm trying to create simple console app and debug it using vs code and c# extension. I have the following issue : When clicking debug button, error appears :

launch: launch.json must be configured. Change 'program' to the path to the executable file that you would like to debug

launch.json path to executable looks like that :

"program": "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>",

this file is autogenerated by VS Code, so what's wrong??? moreover, replacing previous path by full file system path like

Alex/bin/Debug/aspnetcore/projectname.dll"

makes it work. Please, help me, i haven't found anything, i just want to click the "start debugging" button and debug without any problems.

Best wishes, Aleksey

Upvotes: 1

Views: 1342

Answers (2)

Kendra Havens
Kendra Havens

Reputation: 46

For anyone still hitting this issue:

  1. Open up your Program.cs file before starting to debug in Visual Studio Code.
    • Opening any .cs file fires the C# extension.
  2. The extension will then ask if it can load build assets. Hit Yes.
    • It may take a few seconds to load Omnisharp
    • It only asks this if the launch.json and tasks.json haven't already been added to the project.
  3. Then the extension will configure your launch.json and tasks.json for you.

For those interested there is an issue tracking this behavior.

Upvotes: 0

Scott Kuhl
Scott Kuhl

Reputation: 1081

You can leave ${workspaceRoot} in, the issue is with <target-framework> and <project-name.dll>

Here is an example that should work if you are running .NET Core 1.1:

"program": "${workspaceRoot}/bin/Debug/netcoreapp1.1/projectname.dll",

That will get the project to debug on any machine since it is a relative path unless you rename the project. But the Visual Studio Code C# extension should not be auto generating a launch.json file that does not work.

I have opened a bug on this issue: https://github.com/OmniSharp/omnisharp-vscode/issues/1126

Upvotes: 4

Related Questions