Press ‘F5’
The F5
button is the magic button to start debugging. However, if you start debugging the first time, you need to set up VisualStudio Code first. You need to setup a launch.json
file to start debugging and a tasks.json
file to first run the process.
Setup
- Press
F5
- Select
.NET Core
- VS Code generates the
launch.json
file in the.vscode
folder and opens it.
- Edit the
launch.json
file - Insert the configuration entry within the selected square brackets of the ‘configuration’ section
- Press
Ctrl
+Space Bar
- Select
.NET: Launch .NET Core Console App
- Enter the path to the application
.dll
file in theprogram
attribute:"${workspaceFolder}/src/MailBoxTransformer/bin/Debug/netcoreapp3.1/MailBoxTransformer.dll"
- The path differs from the original template because the project is within the
src
sub-folder.
- Press
- Press
F5
again - VS Code now complains that it does not find the
build
task defined in thepreLaunchTask
attribute of thelaunch.json
file - Select
Configure Task
- Select
Create tasks.json file from template
- Choose the
.NET Core Executes .NET core build command
template
- VS Code generates the
tasks.json
file in the.vscode
folder and opens it.
- Edit the
tasks.json
file - If the
.fsproj
file is not in the main folder - Insert the path of the directory containing the
.fsproj
file as an additional argument fordotnet build
."${workspaceFolder}/src/MailBoxTransformer",
- To see the logs of the build task in the console (optional):
- Change the
presentation
attribute in thetasks.json
file
from"silent"
to"always"
- Change the
- Press
F5
again - VS Code runs
- The
dotnet build
process - The app
- The
- Add the
launch.json
and thetasks.json
files located in the.vscode
folder to your source control system (e.g. git).
You are now able to start the build process and the app itself from within VS Code. Now you can set break points and debug your app. I have included the complete launch.json
and the tasks.json
files below. Have fun!
launch.json
- Located in the
.vscode
folder
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/MailBoxTransformer/bin/Debug/netcoreapp3.1/MailBoxTransformer.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole"
}
]
}
tasks.json
- Located in the
.vscode
folder
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "shell",
"args": [
"build",
"${workspaceFolder}/src/MailBoxTransformer",
// Ask dotnet build to generate full paths for file names.
"/property:GenerateFullPaths=true",
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
"/consoleloggerparameters:NoSummary"
],
"group": "build",
"presentation": {
"reveal": "always"
},
"problemMatcher": "$msCompile"
}
]
}