Search code examples
c#visual-studiovisual-studio-extensions

How to register my visual studio extension to run events?


I have a visual studio extension and I want it to run another executable before the program itself is running without debugger (when the program runs with a certain configuration). how can I do that?

I managed to do that when the program is being debugged - I used DTE.Events.DebuggerEvents interface. is there a similar event for running the program without debugger?

private static void EventsRegistering()
{
    DTE2 visualStudioInstance;
    debuggerEvents = visualStudioInstance.Events.DebuggerEvents;
    debuggerEvents.OnEnterRunMode += DebuggerEvents_OnEnterRunMode;
}

Just to be clear - I don't want it to run with every build of the program, just for every run.


Solution

  • You can subscribe to DTE.Events.CommandEvents.OnBeforeExecute and detect when a command name is Debug.StartWithoutDebugging. See for example Monitor commands execution.