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

197 views Asked by At

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!

1

There are 1 answers

4
Evgeny Terekhin On

Please find an example of attaching to a process. You have to implement this logic it on Rider frontend (in kotlin code), not on a backend