Building C# (not .NET Core) Apps in VSCode on Linux

As of 2017, there’s no recent, complete information on how to set up VSCode (Visual Studio Code) to debug C# applications that don’t use the .NET Core. I’m talking about “oldschool” .NET 4.5.1 apps.

Thankfully, this is still possible, and quite easy (once you know the right steps). This only works on Linux and OSX, because of the underlying reliance on mono as the vehicle which provides the debugger.

  • On your Ubuntu machine, run sudo apt-get install mono-complete. This gives you the debugger.
  • Run sudo apt-get install mono-xbuild. This is the Mono equivalent of MSBuild.
  • In VSCode, install the Mono Debug plugin (F1, ext install ms-vscode.mono-debug)
  • Restart the VSCode window/editor when prompted
  • Press F5 to create a tasks.json file. The defaults are fine; just replace the msbuild command with xbuild
  • Press F5; you should see a list of launchers, including a C# Mono one. Select that. It should create a launch.json file.
  • Change the type to mono, change program to point to your executable, and set cwd.
  • Add this block to allow attaching to the debugger:
    "name": "Attach",
    "type": "mono",
    "request": "attach",
    "address": "localhost",
    "port": 55555

Set a breakpoint, press F5, and everything should work!

About Ashiq Alibhai, PMP

Ashiq has been coding C# since 2005. A desktop, web, and RIA application developer, he's touched ASP.NET MVC, ActiveRecord, Silverlight, NUnit, and all kinds of exciting .NET technologies. He started C# City in order to accelerate his .NET learning.
This entry was posted in Tools and tagged , , . Bookmark the permalink.

Leave a Reply

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