How to Programmatically Attach JetBrains Rider's Debugger to a Process in a Plugin

I'm currently developing a plugin for JetBrains Rider (version 2023.2.3). A key feature of this plugin involves creating and running a .NET executable file using System.Diagnostics.Process, which gives me access to the process ID (PID). My goal is to programmatically attach Rider's debugger to this process, similar to how it's done via the UI as described in the Rider documentation https://www.jetbrains.com/help/rider/attach-to-process.html#attach-to-local.

In a similar Visual Studio plugin, I achieve this functionality using the following C# code:

foreach (Process item in _dte.Debugger.LocalProcesses)
{
    if (item.ProcessID == newp.Id)
    {
        item.Attach();
        break;
    }
}

However, I'm facing challenges replicating this in Rider. In my Rider plugin, I'm using IExecutableAction which triggers an execute function. In this function, I have access to the IDataContext from which I can obtain various components like context.GetComponent<ISolutionBuilder>().

Despite trying to get various components related to the Debugger, I haven't found any that offer the functionality to attach to a process. Is there a specific component or method in Rider's API that enables attaching the debugger to a process programmatically?

Any insights or guidance would be greatly appreciated!

0
1 comment

Hi!

Please take a look at this example of attaching to a process. You have to implement this logic on Rider frontend (in Kotlin code), not on the backend

0

Please sign in to leave a comment.