Search code examples
c#.netvisual-studio-2008post-build-eventpre-build-event

Run batch script before Debugging


I want to run a batch script every time before starting program for debugging.

For the build events, such functionality is realized using pre-build event, post-build event.

For actual debugging, I could not find any pre-Debug, post-Debug events.

How to realize this scenario?

I am using VS2008, .net framework 3.5, c# application.

I am opposed to idea of creating some extra lines of code within the application that would fire-up external batch file.


Solution

  • I realise you wished to avoid additional code, but in your Main function you could use Debugger.IsAttached() to kick off your work for you.

    For example:

    if (Debugger.IsAttached)
    {
         System.Diagnostics.Process.Start(@"C:\myBatchFile.bat");
    }