Skip to content

Instantly share code, notes, and snippets.

@marukami
Created July 31, 2017 08:35
Show Gist options
  • Save marukami/c0ad9005861393b078e124596800cc42 to your computer and use it in GitHub Desktop.
Save marukami/c0ad9005861393b078e124596800cc42 to your computer and use it in GitHub Desktop.
Setting up debugging for .NET Core in VSCode
  • Open VSCode in the primary project folder
  • Install C# for VSCode if not already done
    • This contains the .NET Core Debug templates
    • This might be overkill for now, but it work
  • Configure debugger as .NET Core
    • This should create a launch.json under .vscode in the current workspace root folder
  • Try running a debug session
    • This will result in the error Could not find the preLaunchTask 'build'. Press Configure Task Runner
    • Don't worry if you miss click and dismiss the promt, it will show the same error again.
    • Configure Task Runner will ask for a Task Runner again pick .NET Core
    • This will create a task.json that should look similar to the following
{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "taskName": "build",
      "command": "dotnet build",
      "type": "shell",
      "group": "build",
      "presentation": {
        "reveal": "silent"
      },
      "problemMatcher": "$msCompile"
    }
  ]
}

Almost done. Now we need to install the .Net Core Debugger. Open the VSCode command prompt with either (Shift + Command + P) on macOS or (Shift + Control + P) on Windows and run

> Debug: Download .NET Core Debugger

NOTE

Some versions of the .NET Core task templates have a bug where the command property is "command": "dotnet", instead of "command": "dotnet build", command is what is past to the shell. So, Just dotnet by it's self will fail with the error code 129. If you get this error make sure the command has the build parameter.

If you want to pass arguments to the command you can use the task args property; I typically add args below the command property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment