Skip to content

Instantly share code, notes, and snippets.

@caleblloyd
Last active June 24, 2016 14:23
Show Gist options
  • Save caleblloyd/cb4c58a74a859957755e00443611c256 to your computer and use it in GitHub Desktop.
Save caleblloyd/cb4c58a74a859957755e00443611c256 to your computer and use it in GitHub Desktop.
.NET Core remote debugging in Docker with VS Code

Assumptions:

Instructions:

  1. Copy get-clrdbg.sh script into docker container, make executable, and run it. It will install clrdbg to /usr/local/bin
  2. Copy debug.sh to docker container at /root/debug.sh and make executable
  3. Copy launch.json to the root of your VS Code Project and change "aabbcc112233" in "pipeArgs" to the name or ID of your docker container

Hit the Debug button in Visual Studio Code and watch as your code is remotely debugged!

#!/bin/sh
cd $(dirname $0)
cd /dotnet/
dotnet build
exec dotnet exec --additionalprobingpath /root/.nuget/packages /dotnet/bin/Debug/netcoreapp1.0/dotnet.dll
#!/bin/sh
cd $(dirname $0)
if [ ! -f /usr/local/bin/clrdbg ]; then
curl -sSL https://raw.githubusercontent.com/Microsoft/MIEngine/getclrdbg-release/scripts/GetClrDbg.sh \
| bash /dev/stdin vs2015u2 /usr/local/clrdbg && \
ln -s /usr/local/clrdbg/clrdbg /usr/local/bin/
fi
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"program": "/root/debug.sh",
"args": [],
"cwd": "/dotnet",
"stopAtEntry": false,
"sourceFileMap": {
"/dotnet": "${workspaceRoot}"
},
"pipeTransport": {
"pipeCwd": "${workspaceRoot}",
"pipeProgram": "docker",
"pipeArgs": ["exec", "-i", "aabbcc112233", "clrdbg", "--interpreter=mi"],
"pipeEnv": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"windows": {
"pipeCwd": "${workspaceRoot}",
"pipeProgram": "C:\\Program Files\\Docker\\Docker\\Resources\\bin\\docker.exe",
"pipeArgs": ["exec", "-i", "aabbcc112233", "clrdbg", "--interpreter=mi"],
"pipeEnv": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment