Commit 891f9f2
Add MSBUILDDEBUGONSTART=3 to skip debugging TaskHost child processes (#12679)
## Summary: Add MSBUILDDEBUGONSTART=3 to skip debugging TaskHost
processes
✅ **All tasks completed successfully**
- [x] Explore repository structure and understand current implementation
- [x] Understand how MSBUILDDEBUGONSTART works in XMake.cs and
OutOfProcTaskHost.cs
- [x] Identify that DebugUtils.cs has NodeMode detection capability
- [x] Build repository successfully to verify starting state
- [x] Create helper method IsInTaskHostNode() in DebugUtils.cs
- [x] Update XMake.cs to support new environment variable value "3"
(launches debugger conditionally)
- [x] Update OutOfProcTaskHost.cs to handle value "3" (skips debugging
for TaskHost)
- [x] Add tests for the new IsInTaskHostNode() method
- [x] Build and verify the changes work
- [x] Run tests to ensure no regressions
- [x] Manual verification of the feature
- [x] Code review and address feedback
- [x] **Fixed: Added IsInTaskHostNode() check in XMake.cs to handle
sidecar TaskHost processes**
- [x] **Updated documentation to reference new MSBUILDDEBUGONSTART=3
behavior**
- [x] CodeQL security scan
- [x] Final validation
## Changes Made (42 lines added/modified across 6 files):
1. **src/Shared/Debugging/DebugUtils.cs**: Added `IsInTaskHostNode()`
public method to detect if current process is a TaskHost
2. **src/MSBuild/XMake.cs**: Added case "3" with conditional check -
launches debugger only if NOT in TaskHost mode
3. **src/MSBuildTaskHost/OutOfProcTaskHost.cs**: Added case "3" to skip
debugger launch for TaskHost processes
4. **src/Build.UnitTests/BackEnd/DebugUtils_tests.cs**: Added test to
verify IsInTaskHostNode() works correctly
5.
**documentation/wiki/Building-Testing-and-Debugging-on-.Net-Core-MSBuild.md**:
Updated debugging section with new value "3"
6.
**documentation/wiki/Building-Testing-and-Debugging-on-Full-Framework-MSBuild.md**:
Updated breakpoints section with new value "3"
## How to Use:
Set `MSBUILDDEBUGONSTART=3` before running MSBuild to debug the main
process while skipping both:
- MSBuildTaskHost.exe child processes
- Sidecar TaskHost processes running in MSBuild.exe
**Available values:**
- `1`: Launch debugger for all processes (main + TaskHost)
- `2`: Wait for manual debugger attach for all processes
- `3` (NEW): Launch debugger for main MSBuild only, skip TaskHost
processes
## Documentation:
✅ Updated in two wiki pages:
- Building-Testing-and-Debugging-on-.Net-Core-MSBuild.md
- Building-Testing-and-Debugging-on-Full-Framework-MSBuild.md
## Security:
✅ No security vulnerabilities detected by CodeQL
## Testing:
✅ All tests pass (2/2 DebugUtils tests)
✅ Build succeeds with no warnings or errors
✅ Manual verification completed
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
> There is the MSBUILDDEBUGONSTART environment variable that launches
debugging at the start when set. However it launches it also for child
processes that inherit the environment (e.g. the Sidecar TaskHost
processes, which I don't want to debug every time). Please add a new
value for the variable that when set first checks if the current process
is a sidecar taskhost and in that case does not launch debugging.
</details>
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 Share your feedback on Copilot coding agent for the chance to win a
$200 gift card! Click
[here](https://survey3.medallia.com/?EAHeSx-AP01bZqG0Ld9QLQ) to start
the survey.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: JanProvaznik <[email protected]>1 parent f4196fc commit 891f9f2
File tree
6 files changed
+40
-2
lines changed- documentation/wiki
- src
- Build.UnitTests/BackEnd
- MSBuildTaskHost
- MSBuild
6 files changed
+40
-2
lines changedLines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
| |||
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
41 | 50 | | |
42 | 51 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
552 | 552 | | |
553 | 553 | | |
554 | 554 | | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
555 | 562 | | |
556 | 563 | | |
557 | 564 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
108 | 118 | | |
109 | 119 | | |
110 | 120 | | |
| |||
0 commit comments