How to Edit, Compile and Debug .NET program in Linux with Visual Studio Code

When it comes to .NET development in Linux platforms, we don't have enough choice. The best tool to develop .NET applications is Microsoft Visual Studio. Unfortunately, it is not available for Linux. Then Microsoft announced the Visual Studio Code, a free and cross-platform supported IDE. It is not fully featured like Visual Studio itself. But it can do a lot of things with the help of official and community contributed plugins.
Last year, Red Hat blog featured a tutorial that helps to get started with developing .NET applications in GNU/Linux platforms. In this tutorial a sample Music Store app is being considered for demonstration.
One of the best features of Visual Studio is the ability to launch and debug an application from within the IDE. This is not an uncommon feature nowadays. When running .NET on Linux, however, you can’t use Visual Studio as your IDE. What to do?

The answer is Visual Studio Code, a free IDE that will allow you to edit, compile, launch, and debug your application from within your IDE. This post will guide you through this cycle.

Note: I’m using Red Hat Enterprise Linux (RHEL) as my Linux of choice. You can grab your own free developer’s edition of RHEL and run it in a Virtual Machine (VM) on your Windows box (I’m using Oracle’s VirtualBox).

I’ll also be using the sample application, Music Store, which you can grab from GitHub if you wish to follow along. Of course, this blog is applicable to your own code as well.

If you do follow along with the Music Store app, keep in mind that the .NET Core tooling is currently going through a transition from the project.json/xproj standard to MSBuild/csproj, and the Music Store sample is already updated to the new standard. The tooling version from the official .NET website right now is the 1.0.0-preview2, which is still in the old standard. Therefore, in order to run the sample, you should checkout the branch called rel/1.1.0-preview1, which contains the project.json-based version.
Read original tutorial in Red Hat developers blog.

Share this