Today, you will find out if you can finally ditch Visual Studio for VS-Code for C# development. Before 2023, support for C# within VS-Code has been limited, however, this has recently changed. In June 2023, C# Dev Kit for Visual Studio Code was officially released (read more here).
This new VS-Code marketplace extension offers to enhance C# development within the VS-Code IDE, so if you will learn what it offers, how much it costs, and more importantly if it's any good!
By the end of this article, you will be able to make an informed decision if you can kick Visual Studio to the curb for good. Sound good, read on 🔥🔥🔥
The first C# marketplace extension that was released for VS-Code was CSharp. This extension enhanced VS-Code with additional C# capabilities like refactoring, code navigation, and code completion and giving the IDE better .NET specific semantic awareness.
As of June 2023, there are now two additional C# related extensions that you can install:
Combining these two new extensions will provide you with more C# related capabilities within VS-Code, however, the big question is will these new features be enough to tempt you away from Visual Studio?
Your first consideration of why you might want to ditch Visual Studio is cost saving. C# Dev Kit is available for free under a community license. The community license means that it's free for use by hobby developers, academics, on open-source projects and within teams of up to 5 people. For companies with over 6 developers, you will still need a Visual Studio Professional subscription to use this extension. So just in terms of price, there's no real benefit of using VS-Code over Visual Studio for C# development!
After installing both extensions, the first thing you will notice is better support for creating new C# projects. Within VS-Code, you will now see a new tab within Solution Explorer called
Solution Explorer. The main thing to call out within this tab is a button that will allow you to
Create New .Net project. For reference, you can also trigger the same command via an option within the VS-Code command pallet.
Selecting this option will launch a wizard that will allow you to pick which one of your pre-installed .NET templates you would like to use to generate your files. A good new addition to VS-Code here is that this installer will also create a solution file for you. This was previously not possible in VS-Code!
After you have loaded a C# solution/project, within the new
Solution View tab you can right-click on your project and you will have the option to either
clean your project from the context menu just like in Visual Studio. You will also get access to all the same context menu options that you would expect to find in Visual Studio if you right-click on a unit test project instead.
Sadly, there is no way to set which environment you want to run these commands against. With no UI creator or switcher for environments in VS-Code, you will need to manually set the environment as well as define new ones in code within your solution file. I assume the default wizard will create a new project set to build in
debug mode, however, this could trip you up if you are not consciously aware of it!
Another limitation of only using VS-Code for your day-to-day IDE is managing project dependencies. Currently, there is no inbuilt NuGet browser for VS-Code. This means that you will have to rely solely on the terminal to install and manage all the Nuget packages that you want to use within your solution.
No environment or package manager support means that Visual Studio wins hands down as a day-to-day IDE to manage C# projects.
Another reason for not using VS-Code solely as your C# IDE of choice is the Visual Studio-specific extensions. I use tools like Resharper and Code Maid daily to help me write code quicker, however, there are no VS-Code C# equivilants of these yet. With C# Dev Kit being released this might change, but, currently you will get much better C# support in Visual Studio!
In terms of day-to-day refactoring like renaming a class, the extension does a good job of making sure all the related files get updated as well. C# Dev Kit is powered by Rosyln so it's faster at applying these refactorings compared to the existing
C# VS-Code package. The UI feels fairly snappy when you make global changes and I've not noticed any annoying lags.
One issue that I did encounter when using C# Dev Kit was when creating a new MVC Razor view (CSHTML). When you create a new view, the project's default namespace was not automatically added to the view. Also, when I refactored namespaces, the values in my views often didn't automatically update correctly. Again, not a show-stopper but an annoyance!
To recap, C# Dev Kit is definitely a positive move forward for .NET developers who also use VS-Code. Personally, there are still too many things missing in C# Dev kit/VS-Code for me to remotely consider this extension as a replacement for Visual Studio yet.
I definitely find using VS-Codes text editor quicker and faster to write a line of code compared to Visual Studios' clunkiness, however, to manage and debug the solution in anger you are still much better off sticking with Visual Studio for now.
If you need a way to quickly test and write C# code and view files when you are already in VS-Code then this is a neat add-on and it is a good leap forward for C#
Over time who knows what other new features we will get in VS-Code. If the gap closes enough it could be a Visual Studio killer one-day, however, for now C# Dev Kit is more of a handy-to-know-about tool rather than an essential one. Happy Coding 🤘