Simon Bisson
Contributor

Using Visual Studio Code for C# development

analysis
Oct 11, 20238 mins
C#Development ToolsIntegrated Development Environments

Microsoft’s new C# Dev Kit extension for Visual Studio Code turns the programmer’s editor into a complete development environment for .NET.

Developers work together to review lines of code in an office workspace.
Credit: Joyseulay / Shutterstock

Microsoft’s Visual Studio is its primary development environment, delivering end-to-end support for the application development lifecycle. It’s a powerful tool, but it remains dependent on Windows and it can be overkill for many development tasks. That’s where Visual Studio Code comes in. 

Able to run on Windows, Linux, or Mac, exceedingly extensible, with excellent support for remote development, Visual Studio Code fills many of the gaps in Microsoft’s developer story. It’s still a quick and easy tool to use, but has come to transcend its original role as a programmer’s editor. Now, with the arrival of Microsoft’s C# Dev Kit, Visual Studio Code becomes a viable alternative to Visual Studio for .NET development.

The power of VS Code plugins

Much of the utility of Visual Studio Code comes from its large library of first-party and third-party plugins. These add many key features to the core editor, providing dedicated language support alongside tools that support many different development styles. By adding your choice of plugins, you can quickly build a development environment that’s tailored to your specific needs. Those needs don’t need to be mainstream—in fact there’s support for many niche languages and services.

Niche is good, but the success of a development platform is measured by its support for the mainstream. That’s how you get millions of users, ensuring Microsoft’s ongoing support and development. After all, it was the rapid growth and enduring popularity of Visual Studio Code that put the final nail in the coffin for GitHub’s Atom editor.

That popularity is driving an interesting shift in how Visual Studio Code is being treated. It’s at the heart of many recent developer initiatives from both Microsoft and GitHub, including the GitHub Copilot generative AI coding assistant and Microsoft’s cloud-hosted Dev Boxes.

Introducing the C# Dev Kit

So, it’s not surprising to see Microsoft deliver the tooling necessary to make Visual Studio Code a full-fledged C# development environment, with the launch of the C# Dev Kit. We’ve seen similar forays before, with bundles of extensions and runtimes for both Python and Java, but this release gives Visual Studio Code everything needed to fully participate in the .NET ecosystem, on all of .NET’s supported platforms.

Installation is quick and easy, with the C# Dev Kit bundling the C# extension, IntelliCode tool for AI-powered code completion, linting, and syntax highlighting, and the .NET runtime for compilation and debugging. Once installed, the C# Dev Kit adds a Solution Explorer view, helping manage code more effectively with a view similar to that used in the Visual Studio IDE. Under the hood, the C# Dev Kit is powered by .NET’s Roslyn compiler, which provides the foundations for the tool’s more advanced features. You’ll need to install the .NET SDK separately, to ensure you have the full .NET environment with support for tools like NuGet.

If you prefer a less proactive development environment, you can uninstall the IntelliCode tooling without affecting the rest of the C# Dev Kit. This falls back to Visual Studio Code’s native C# tooling.

Using the C# Dev Kit with Visual Studio Code

The best way to use the C# Dev Kit is alongside the .NET CLI that’s part of the .NET SDK. From the CLI you can create your application using familiar templating tools. If you then launch Visual Studio Code from inside that directory it will open the main C# file for your project, along with the new Solution Explorer view for your code. You can run your code from the Visual Studio Code terminal or use the built-in debugger for more detailed analysis.

The C# Dev Kit adds more in the way of code navigation tooling, using the Solution Explorer to work with test frameworks and the Roslyn tools to quickly jump to specific parts of your application, peeking at definitions and references to understand how classes and methods are used. The Solution Explorer helps manage complex projects, using virtual solution folders to group files without affecting your underlying file system. Solution folders let you separate code from tests, as well as managing different UIs for different device targets.

The IntelliCode extension adds AI-supported code completion to your editor, with the ability to predict entire lines of code, based on what you’ve already written. This works alongside the normal IntelliSense features to guide code predictions, reducing the risk of errors. It will even highlight possible completions in IntelliSense and rank the members in a class based on your code to speed up selections.

It’s important to understand that this is a local AI model. Unlike GitHub Copilot, IntelliCode operates disconnected from the internet, helping keep code secret and enabling you to work from anywhere.

Other tools in the C# Dev Kit improve Visual Studio Code’s refactoring support, adding Quick Fixes that suggest possible changes using a lightbulb icon. Commands can be accessed from the Visual Studio Code command palette, giving you a keyboard-driven approach to command navigation.

While the C# Dev Kit tools are good enough to work with, note that pieces are still missing. For example, if you’re managing dependencies, you currently need to work with the .NET command line tools, as there’s no support inside the editor. That’s less of a problem than it seems, because the built-in terminal ensures you won’t lose context—especially if you’re using it to test code and deploy templates.

C# development on the Mac

Microsoft’s announcement of the end of life for Visual Studio for Mac leaves C# Dev Kit as the only official .NET development environment for macOS. That’s probably not a bad thing, as Visual Studio for Mac was only ever a rebranded version of Xamarin’s developer environment. As a result, it never achieved parity with Visual Studio for Windows. By contrast, Visual Studio Code receives regular updates, and its healthy plugin ecosystem gives you plentiful options for development.

Installing the C# Dev Kit on a Mac is simple enough. I use a MacBook Air with Apple’s M2 Arm processor, so when offered the option of installing either a universal or Apple Silicon build of Visual Studio Code, I chose the Apple Silicon option. This downloads as a zip archive, and once unzipped, you can drag the Visual Studio Code binary into the macOS applications folder, ready for use from the Launchpad.

With Visual Studio Code running, you’re ready to install the C# Dev Kit. If you’re working on cross-platform UI, you can install Microsoft’s MAUI plug-in to use the next generation of Xamarin forms (note that MAUI is still under development). Other UI tools, like the Uno Platform, can be installed alongside the C# Dev Kit, allowing you to mix and match UI components.

It’s a good idea to run Visual Studio Code alongside an install of Apple’s Xcode, as this allows you to build and test for iOS and iPadOS, as well as macOS. This is one advantage of using a Mac as a .NET development environment, as you can use it to build for most target platforms. Because Visual Studio Code offers support for various Git tools, including GitHub, you’re able to share code across PC (both Windows and Linux) and Mac, with one repository edited and tested wherever you want.

A cross-platform development platform

A combination of Mac and Windows gives you the best possible choice of tooling for the maximum range of target environments. Windows gives you Linux and Android through Windows Subsystem for Linux and Windows Subsystem for Android, while the Mac supports Apple’s mobile platforms. It’s a pity you can’t have everything on one PC, but licensing restrictions ensure that effective cross-platform development requires more than virtual machines and emulators.

One important point to note is that getting the most from the C# Dev Kit requires a Visual Studio account. That’s because the C# Dev Kit uses the same licensing model as Visual Studio, including being free for individual users and open source projects. Enterprises will need an appropriate Visual Studio license or a subscription to GitHub Codespaces.

If you don’t want a heavyweight development experience, the combination of Visual Studio Code and the C# Dev Kit provides a quick on-ramp to .NET development on any supported platform—whether it’s on your desk or over a remote connection. The result is an intuitive and flexible C# development environment that works with other Visual Studio Code extensions to build a custom editing experience that supports the projects you’re building and the way you want to work.

Simon Bisson
Contributor

Author of InfoWorld's Enterprise Microsoft blog, Simon Bisson prefers to think of “career” as a verb rather than a noun, having worked in academic and telecoms research, as well as having been the CTO of a startup, running the technical side of UK Online (the first national ISP with content as well as connections), before moving into consultancy and technology strategy. He’s built plenty of large-scale web applications, designed architectures for multi-terabyte online image stores, implemented B2B information hubs, and come up with next generation mobile network architectures and knowledge management solutions. In between doing all that, he’s been a freelance journalist since the early days of the web and writes about everything from enterprise architecture down to gadgets.

More from this author