Debug code running in XC containers
This topic explains how to use Visual Studio to view and diagnose your Commerce Engine code when it is running in a local Docker container. It assumes that you know how to build and run custom Docker runtime images that include the build output for your Commerce solution.
To debug apps in a local Docker container, you must use Visual Studio 2019 version 16.5.0 or later.
Though not unique to containers, you must ensure that debug symbols have been deployed to the container. This might already be done if you are building your solution image with the Debug build configuration.
You can also do a Debug file deployment from Visual Studio into the running container.
In Visual Studio, you have two options for attaching the debugger to a process in a container:
Option 1: Attach the Visual Studio debugger using the Containers window
To attach the Visual Studio debugger to a process running in a container:
-
If the Containers window is not showing, open it from the top View menu. Click Other Windows, then Containers.
-
In the list of running containers, right-click the one that you want to debug, for example container_engine_authoring_1, and click Attach to Process:
The Attach to Process dialog opens.
-
In the Attach to Process dialog, to debug a Commerce Engine dotnet.exe process, use code type Automatic: Managed(.NET Core, .NET 5+)code, as shown in the following example:
-
Click Attach.
Option 2: Attach the Visual Studio debugger using the Debug menu
Alternatively, you can use the Visual Studio Debug menu.
To attach the Visual Studio debugger to a process running in a container:
-
In Visual Studio, in menu bar, click Debug, and then click Attach to Process. The Attach to Process dialog box opens.
-
In the Connection type, drop-down list, click Docker (Windows Container).
-
In the Connection target field, click Find. Running containers appear in the list. Click the container you want to debug, and click OK.
-
In the Attach to field, select the correct type. To debug a Commerce Engine
dotnet.exe
process, use code type Automatic: Managed(.NET Core, .NET 5+)code. -
Click Attach.