Debugging C# on OS X with Visual Studio Code

Thanks to this helpful Tweet I was able to use Visual Studio Code to debug C# code on Mac OS X:

Here’s how you can get going from start to finish:

  1. Install DNX
  2. Fire up your Terminal emulator
  3. Execute yo aspnet & choose Console Application
  4. Execute dnu restore
  5. Launch Visual Studio Code & open the ConsoleApplication folder generated by Yeoman
  6. Click Debug button followed by the Gear button
  7. Replace or add this entry to launch.json:
    {
        "name": "Launch ConsoleApplication",
        "type": "mono",
        "program": "Program.exe",
        "stopOnEntry": true       
    }
  8. Invoke the Command Palette (⌘P) & choose Configure Task Runner
  9. Replace the existing entry for tsc in tasks.json with the following entry:
    {
        "version": "0.1.0",
        "command": "mcs",
        "args": [
            "-debug",
            "Program.cs"
        ],  
        "showOutput": "silent",
        "taskSelector": "/t:",
        "tasks": [
            {
                "taskName": "exe",
                "isBuildCommand": true,
                "problemMatcher": "$msCompile"
            }
        ]
    }
  10. Invoke the Command Palette and choose Build Task (↑⌘B)
  11. Click the Debug button and, finally, click the Play button (F5)

Debug C# on OS X with VS Code

\o/

Thanks @weinand!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>