Pivotal Knowledge Base


How to Debug .NET Core Applications on Pivotal Cloud Foundry


  • Pivotal Cloud Foundry (PCF)
  • Applications using .NET core buildpack


There is now a way to debug .NET Core application from Visual Studio on PCF with Linux cells. The solution involves hooking into MI Debug engine to pipe debugging data over SSH. While Visual Studio does have support for debugging over SSH, it expects you to provide ip, port, and credentials. Hooking into “cf ssh” is a trickier - here’s how you do it.


First, we need to bundle CLRDBG with your application. The official release of clrdbg requires the presence of libunwind on the cell, which is not included currently. However, we can still make it work by bundling the required dependencies from libunwind into clrdbg. There is now a custom clrdbg package which includes the necessary libunwind dependencies, which is published here: https://github.com/macsux/cfdotnetdebug/releases/download/1.0/clrdbg-ubuntu.14.04-x64-libunwind8.zip. From here, we need to bundle it with the artifacts we’re publishing (in future this should be done via buildpack). From there we going to ssh into our container and record the PID of the app we’re going to attach debugger to. This is fed into an “instructions” xml file for the debugger, which includes the command to use cf ssh and the process ID we want to attach to. Finally we use a special command in visual studio in order to use this xml file to spawn our debug session. 

Step by step:

  1. Download CLRDBG with libunwind
  2. Publish your app with debug symbols dotnet publish -f netcoreapp2.0 -r ubuntu.14.04-x64 -c Debug -o publish
  3. Extract the downloaded zip into your publish\clrdbg folder
  4. cf push the app from the publish folder
  5. Create launch.xml file as following:
<PipeLaunchOptions xmlns="http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014"
                   PipeArguments="ssh YOUR_APP_NAME -command &quot;~/app/clrdbg/clrdbg --interpreter=mi&quot;"

Make sure to adjust PipeArguments

  1. Run the following command and record PID of your app
  2. > cf ssh YOUR_APP_NAME --command "ps -d"
  3. Replace the value of ProcessId in launch.xml with PID for your app
  4. From Visual Studio, open Command window (View > Other Windows > Command Window)
  5. Run the following in VS Command Window

Debug.MIDebugLaunch /Executable:dotnet /OptionsFile:"C:\FULL_PATH\launch.xml"

We should now be debugging.

Additional Information

Dotnet-core on github: https://github.com/cloudfoundry/dotnet-core-buildpack

User guide: https://docs.cloudfoundry.org/buildpacks/dotnet-core/index.html


Powered by Zendesk