Using the C# Dev Kit Extension for Development

Ben
6 min readJul 14, 2023

--

With news of the .NET C# Dev Kit extension coming to VS Code I figured I’d attempt to switch entirely over to using it. I, admittedly, am a fan of Visual Studio. For C# development it is the king. The tools, ease of use, and always improving feature set make it a no brainer for to use.

Visual Studio does have a few problems. Hot reload doesn’t always seem to work as good as the CLI hot reload. Visual Studio’s intellisense seems to stop from time to time. I’ve had to reinstall Visual Studio a few times this year, 2023, just to resolve some of the other weird one off bugs.

So that got me thinking, what would a VS Code and C# workflow look like? So, I made the decision to try to do all my work using this new fancy extension.

The Installation

This is pretty straightforward. Install the C# Dev Kit from the extension browser. This installs all the required extensions into VS Code. These are: The C# Extension, IntelliCode for C# Dev Kit, and the .NET Runtime Install Tool. Next comes learning about all the commands to get a workflow going.

Working with an Existing Project

According to the official documentation we next just need to use the “Open Folder” option in VS Code to find the root of a project that has a solution file.

https://code.visualstudio.com/docs/csharp/project-management#_solution-explorer

It does take a little time for it to find and load the solution file. So, if it doesn’t work or doesn’t load quick enough you can access the command pallet with F1 or Ctrl+Shft+P then run the .NET: Open Solution command.

Intelligence works, peeking at code definitions works the same, and the shortcuts are a little different but easy to learn or change accordingly.

Debugging the Project

Building and then running your code. The most important thing in development! Supposedly it should work just like the OG Visual Studio. However I had a slightly different experience.

The first time I pressed F5 is came up with a few options from which to choose.

Multiple Options when Pressing F5 for the First Time

As you can see the suggested option is .NET 5+ but it has a long list of options. This example is from a Web Api project. Selecting the .NET 5+ option results in the command pallet disappearing and then nothing happening.

Pressing F5, the same list of options appears before me. I then tried using the Web App (Chrome) option which then sets me up to launch my code but doesnt set the appropriate port number. We run on port 5011 and it set me up to run on port 8080.

Updated debug launch options when selecting Web App (Chrome) from the Debug Options

Well, it turns out you have to be very specific about where you press F5 from.

You see our project is setup in an N-Tier fashion and thus we have a Applicaiton Project, Services Project, and a Data Project. In Visual Studio I can be anyway in the solution, press F5 and it just loads and debugs the preconfigured start project. With the C# Dev Kit extension in VS Code you have to be on the file, in the project, you want to debug.

The difference doesn’t stop there, however. Upon pressing F5 in a file on the project I want to debug I, again, am prompted to select a debugger option. This time I have a more limited selection of options.

New List of Debugger Options

Again, .NET 5+ is suggested but doesn’t actually do anything. Instead you want to use the C# debugger. Then if you have multiple projects it finally prompts you to select a default startup project. Once you’ve gone through this process you are now able to press F5 and simply jump right into debugging.

Don’t you know you have to setup things in Visual Studio sometimes?

Yes, I hear your internet thoughts loud and clear. While there is some setup involved in debugging with Visual Studio a lot of that is pre-configured for you. You can simply create a project, jump in, and press F5.

Most C# developers are going to be use to that world and even newer developers may not even realize how to configure these things right off the bat.

Visual Studio makes it easy to load up, and start working. The C# Dev Kit relies on you having some more intermediate knowledge about projects, solutions, debugging, and configuration. This isn’t a bad thing, by any means, and does help you learn the ins and outs of the development process.

Interface Comparision

The user interfaces between these two products are similar in some ways and drastically different in others. And in the end it comes down to personal preference of which you like better.

Visual Studio has more windows, tools, etc. at your disposal. But the customization is more restricted. Visual Studio Code is extremely extensible but not everything is available or is available at the same quality as found in the premade tools in Visual Studio. Visual Studio UI customizations are plentiful in contrast to that of Visual Studio.

They did try to make the Solution Explorer for the C# Dev Kit appears almost identical to Visual Studio.

Solution Explorer in VS Code

As mentioned before there are a few restrictions currently. One such restriction is the use of a graphical package manager for NuGet. While you can see your dependencies you can’t right-click to add a NuGet package.

This also means that if you use a private NuGet feed and the standard NuGet feed like we do things can be a touch more difficult to manage. You will need to learn the dotnet restore commands and rely on the CLI to do most of your package management. In my case I will have to always point to the correct package feed via the CLI since our internal NuGet feed doesn’t pull from NuGet on its own.

This is a pretty common practice in other languages but for those that love the NuGet Package Manager Console in Visual Studio it may be a little hard to get used to.

Final Thoughts and TLDR

The experience is different from the normal Visual Studio one. You get more control with Visual Studio Code and the C# Dev Kit while being less refined. Visual Studio gives you a more refined, complete, but restrictive workflow.

However, the C# Dev Kit requires you to have a license in order to use it. Visual Studio’s Community Edition gives you a lot more for that zero-dollar price tag.

With that in mind I would still urge people to use Visual Studio. It’s a free, refined, and excellent option. Visual Studio Code may a more “purist” way to code and help you learn the workflow underneath, but I don’t think I’d pay a price for it.

--

--