In this blog post, we’ll show you how to use Dev Containers for .NET development.

The VS Code Dev Containers extension allows you to develop .NET and other applications inside a containerized environment that is isolated from your host machine. This means you can work within a clean, consistent, and reproducible setup every time—without polluting your local development environment.

Why Use Dev Containers?

Using a container as your development environment lets you build applications inside a stable and preconfigured environment that is portable and easy to share across different machines and teams. It also ensures consistency regardless of the developer’s operating system or local dependencies.

Requirements

To use Dev Containers, you’ll need:

  • Docker Desktop installed on your machine
  • Visual Studio Code (VS Code)
  • The Dev Containers extension for VS Code

Getting Started

  1. Open VS Code in a new window.
  2. Press Ctrl+Shift+P (or Cmd+Shift+P on macOS) to open the Command Palette.
  3. Search for and select Dev Containers: Open Folder in Container.
  4. Choose the folder where your .NET application is located.
  5. Follow the prompts to select a .NET image (e.g., .NET 8, 9, or 10) and the .NET CLI tool.

Behind the scenes, the extension will pull the selected Docker image, set up the container, and mount your project folder into it.

Development in a Dev Container

Once your Dev Container is running, you can:

  • Use VS Code to edit your .NET project as usual.
  • Run terminal commands like dotnet run, dotnet build, or dotnet test directly inside the container.
  • Enjoy a consistent, version-controlled development environment.

Summary

Dev Containers are a powerful way to modernize your development workflow, especially for teams or developers working across different machines. By containerizing your dev environment, you eliminate the classic “it works on my machine” problem and streamline onboarding for new team members.


Discover more from CPI Consulting Pty Ltd Experts in Cloud, AI and Cybersecurity

Subscribe to get the latest posts sent to your email.

Discover more from CPI Consulting Pty Ltd Experts in Cloud, AI and Cybersecurity

Subscribe now to keep reading and get access to the full archive.

Continue reading