Run batch script before Debugging
You can use a VS macro.
I had the same issue and this is the best I came with so far
Dim MustUpdateDB As Boolean
Private Sub DebuggerEvents_OnEnterRunMode(ByVal Reason As EnvDTE.dbgEventReason) Handles DebuggerEvents.OnEnterRunMode
If (MustUpdateDB) Then
MsgBox("Start debug operation", MsgBoxStyle.OkOnly, "TITLE")
REM DO WHATEVER COMMAND HERE
REM System.Diagnostics.Process.Start("C:\listfiles.bat")
MustUpdateDB = False
End If
End Sub
Private Sub BuildEvents_OnBuildDone(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildDone
MsgBox("Build Done", MsgBoxStyle.OkOnly, "Title")
MustUpdateDB = True
End Sub
There is a pretty good explanation on how to add event handlers to a macro here
The only issue I have so far is to figure out how to get the currently debugged application active directory
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");
}