Version 1.107 is now available! Read about the new features and fixes from November.
Dismiss this update
Install the .NET SDK, which includes support for attaching to the .NET debugger. With .NET SDK 7 or later, you have the option of debugging without a Dockerfile.
Install the Visual Studio Code C# extension, which includes support for attaching to the .NET debugger with VS Code.
macOS users only: Add /usr/local/share/dotnet/sdk/NuGetFallbackFolder as a shared folder in your Docker preferences.

dotnet new.There are two ways to build and debug your app inside a container: using a Dockerfile or, for .NET 7 and later, without a Dockerfile.
Dockerfile)This option is supported for web projects, and is available when Docker is set to use Linux containers.
launch.json, you can comment them out with ⌘/ (Windows, Linux Ctrl+/))Dockerfile (Use a Dockerfile) or build using the .NET SDK (Use .NET SDK), select Use .NET SDK.Note: Supported .NET SDK Versions: This feature is available for .NET SDK version 7.0.300 and above by default. For versions between 7.0.100 and 7.0.300, enable it with
dotnet add package Microsoft.NET.Build.Containers. You can read more about .NET SDK Container build on Microsoft Learn.
DockerfileWait until a notification appears asking if you want to add required assets for debugging. Select Yes:

Open the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)) and enter Containers: Add Docker Files to Workspace.... If you have already containerized your app, you can instead do Containers: Initialize for container debugging. Follow the prompts.
Switch to the Run and Debug view (⇧⌘D (Windows, Linux Ctrl+Shift+D)).
Select the Containers: .NET Launch launch configuration.
Start debugging! (F5)
To enable SSL (using the HTTPS protocol), you will need to make a few changes to your configuration.
In the Dockerfile, add an EXPOSE line to the base section to define a separate port for HTTPS / SSL. Keep a separate EXPOSE line with a different port for HTTP requests.
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 5000
EXPOSE 5001
In the .vscode/tasks.json file, add configureSsl: true to the netCore section. Also, add an environment variable ASPNETCORE_URLS in the dockerRun section of the docker-run: debug task, with the same port numbers you defined in the Dockerfile:
dockerRun: {
"env": {
"ASPNETCORE_URLS": "https://+:5001;http://+:5000"
}
}
netCore: {
"appProject": "${workspacefolder}/MyProject.csproj",
"enableDebugging": true,
"configureSsl": true
}
For additional customization options, see the documentation on Tasks and Debug containerized apps.
If you have a workspace folder with multiple .NET project files and you want to exclusively debug one specific project (without being prompted to choose from a list of project files every time you F5), you can save your launch profile by following these steps:
Follow the steps in .NET SDK Container Build and keep the debug session live.
Click on the gear icon in your debugger view.

Select Containers: Debug in Container
Choose the project file associated with the project you want to debug
Your project preference is saved, and you no longer need to choose a project file on F5