Attachment Issues
This directly impacts us in the Sitecore world when developing for XM Cloud or using containers, but these same steps apply to anyone who needs to attach to (a) process
inside of container from Visual Studio for debugging.
How To Debug Using Attach To Process Inside A Container
In the case of Sitecore XM Cloud dev environments the Content Management server is running on IIS inside of a container. Let’s take a look at the few simple steps.
Find the following path through the menu View > Other Windows > Containers
.
In the Containers
window right-click on the container of your choice. In our case, we’re going to right-click the container ending in dev_cm_1
, then select Attach to Process
.
To ensure we’re finding the right process in the correct mode, ensure Show processes for all users
is checked, that we’re attaching to Managed (.NET) code
and finding the w3wp.exe
process.
Double-check that we have the latest code building in debug
mode deployed to your container, you should be able to hit your breakpoint.
Please note, you can right-click on your project in the Solutions Explorer window and select Publish
to push your updated C# code into your container for testing without doing an entire compose down and up.
In Closing
This example was done on Visual Studio 2022 using Windows Server. I did not encounter any errors or have to do any additional configuration but one person I shared this with did encounter a sort of certificate or trust error when trying to attach to process. Windows, don’t ever change.
Happy debugging and thanks for reading.