Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #
Context
We crated a utility in vstest to automatically attach child processes back to VS, because having to find them in process tree and manually attach is annoying. Especially figuring out which process is the correct one to attach to, when there are many processes.
A similar approach with Debug.Launch is less manual, but still requires clicking, and does not allow attaching multiple processes to single VS.
This utility solves all that, you simply set env variable (we usually use it without any default breakpoint (what is set as MSBUILDDEBUGNOBP=1 in this PR), so VS attaches and detaches if it does not find any of your breakpoints (e. g. you are debugging a specific task).
Changes Made
Adding
$env:MSBUILDDEBUGONSTART=3;
to attach to VS automatically.Testing
Notes
Currently the tool looks for parent VS because we in vstest we run from a playground project that has parent VS. If it cannot find it, it looks for the first VS (by process startup time). You can provide VS PID, or process that is a child of VS, but that is too manual, and a better way to figure out the right process to attach is needed. E.g. one that has MSBuild.sln opened.