Not quite as elegant as Jaco's answer (never realised you could have multiple startup projects), but may be quite useful. I have a VS macro:
Function AttachToProcess(ByVal procname As String, ByVal quiet As Boolean) As Boolean
Dim attached As Boolean = False
Dim proc2 As EnvDTE80.Process2
' Attaching natively, from http://blogs.msdn.com/jimgries/archive/2005/11/30/498264.aspx '
Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
Dim dbgeng(1) As EnvDTE80.Engine
dbgeng(0) = trans.Engines.Item("Native")
For Each proc2 In DTE.Debugger.LocalProcesses
If (proc2.Name.Contains(procname)) Then
proc2.Attach2(dbgeng)
attached = True
Exit For
End If
Next
If (attached = False And quiet = False) Then
MsgBox(procname + " is not running")
End If
Return attached
End Function
Sub AttachToMyProcess1()
AttachToProcess("MyProcess1.exe", True)
End Sub
Sub AttachToMyProcess2()
AttachToProcess("MyProcess2.exe", True)
End Sub
I then attach the AttachToMyProcessX()
macros to keyboard shortcuts. This has the advantage that you can attach to a process retrospectively: hitting Ctrl-F5 then attaching is often quicker than starting with F5.