C# – Run batch script before Debugging

cnetpost-build-eventpre-build-eventvisual-studio-2008

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.

Best Answer

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");
}