ASP.Net core 2.0 docker container debugging

I was recently working on setting up a Docker container to run “ASP.Net core 2.0” website in debug mode. I was able to run in regular container hosting mode but after following a tutorial for ASPNet core 1.1, I tried to follow the steps and failed. Since I was new with Docker so it took a while to get it working but here is what I had to do make it work:

Original debugging tutorial suggested:

  1. Create a Docker file with this specific command for CLR debugger:
RUN apt-get update && apt-get install -y unzip

WORKDIR /clrdbg

RUN curl -SL \
        https://raw.githubusercontent.com/Microsoft/MIEngine/getclrdbg-release/scripts/GetClrDbg.sh \
        --output GetClrDbg.sh \
    && chmod 700 GetClrDbg.sh \
    && ./GetClrDbg.sh -v latest -l . \
    && rm GetClrDbg.sh

2. Add following to launch.json file:

"pipeTransport": {            
                "pipeProgram": "/bin/bash",            
                "pipeCwd": "${workspaceRoot}",            
                "pipeArgs": ["-c",            
                    "docker exec -i dev_debug_1 /clrdbg/clrdbg --interpreter=mi"]
            }            

There were two issues. Apparently “clrdbg” doesn’t work with Dotnet core 2.0 (C#) anymore and other issue was that “pipeTransport” now requires debugger path attribute.

Solution:

1. In your docker file, use following command for “vsdbg” (instead of clrdbg):

RUN apt-get update && apt-get install -y unzip

WORKDIR /vsdbg

RUN curl -SL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /vsdbg

    2. Use following for “pipeTransport” in launch.json for (“.net launch web”)debugging support:

"pipeTransport": { 
   "pipeProgram": "docker", 
   "pipeCwd": "${workspaceRoot}", 
   "pipeArgs": ["exec -i dev_debug_1"], "debuggerPath": "/vsdbg/vsdbg", "quoteArgs": false }

Then just click the “debug run” button in Visual Studio Code, it should work if the container is already running.

Advertisements

Tags: , , ,

About prres

I have been working with Microsoft Tools and Technologies for 9 years. Most of my work include architecting and developing with C#, ASP.Net, Silverlight and SQL Server.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: