Using Visual Studio Code for C# (.NET Core) development

Published: 06 August 2017


Lately I have been using my Mac as my main daily driver. I still spin up Parallels from time to time when I need to do something inside Visual Studio, but for most of my C# work I use VS Code (and .NET Core). This blog post contain some notes about using VS Code for your C# and .NET Core development which may make your life easier.

As a side note, I have also actually started looking seriously into JetBrains Rider as I miss the powerful refactoring capabilities from Resharper.

Installation

Installation of VS Code and the .NET Core command line tools are pretty straight forward and many resources are available. For installing VS Code you can refer to the Setup section of the official documentation. It provides step-by-step instructions for Windows, Linux and Mac.

For dowbloading the .NET Core SDK you can refer to the Download section of the .NET website. You can also refer to the Get Started with .NET Core document which contains more detailed steps. It also contains a nice video walkthrough of installing both VS Code and .NET Core.

Documentation

The Visual Studio website contains pretty amazing documentation which will help you get started with the basics of using the editor. Also refer to Working with C# to get a better understanding of the C# support inside VS Code.

Extensions

Out of the box, VS Code has very limited support for C#. It does however allow you to enrich the standard functionality by installing extensions. You can discover extensions either from inside VS Code, or from the Visual Studio Code Marketplace.

The VS Code Extension Marketplace document contains more information about how to install extensions. Also refer to Using Extensions in VS Code which contains a video walktrough of installing extensions.

Below are some extensions I recommend you install to get the most from VS Code for C# (and ASP.NET Core) development.

Extensions for C

  • C#. This extension adds Syntax Highlighting, Intellisense, Go To Definition, Find All References, etc. It also add debugging support for C# applications.

    For Debugging I also suggest you refer to Instructions for setting up the .NET Core debugger

  • C# Extensions. This adds functionality to easily add a new C# class or Interface. This is useful because just creating a new file inside VS Code simply creates an empty file. This extension creates a new file for a class or interface for you, and also sets up the correct namespace for your project, as well as include the basic import statements.

  • C# Snippets. Contains many useful C# code snippets.

  • C# XML Documentation Comments. Makes adding XML comments to your code a much more pleasant experience.

Extensions for ASP.NET Core

Others

Refactoring

One major pain point coming from Visual Studio (and Resharper) is the lack of proper code refactoring tools. There is however some hope, as you can - with some manual effort - get some of the Visual Studio Roslyn-based refactoring extensions to work inside VS Code.

For more information on how to do this, please refer to Using Roslyn refactorings with OmniSharp and Visual Studio Code by Filip W. It is not a perfect solution, but it is a good start.