Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 20, 2025

Summary: Add MSBUILDDEBUGONSTART=3 to skip debugging TaskHost processes

All tasks completed successfully

  • Explore repository structure and understand current implementation
  • Understand how MSBUILDDEBUGONSTART works in XMake.cs and OutOfProcTaskHost.cs
  • Identify that DebugUtils.cs has NodeMode detection capability
  • Build repository successfully to verify starting state
  • Create helper method IsInTaskHostNode() in DebugUtils.cs
  • Update XMake.cs to support new environment variable value "3" (launches debugger conditionally)
  • Update OutOfProcTaskHost.cs to handle value "3" (skips debugging for TaskHost)
  • Add tests for the new IsInTaskHostNode() method
  • Build and verify the changes work
  • Run tests to ensure no regressions
  • Manual verification of the feature
  • Code review and address feedback
  • Fixed: Added IsInTaskHostNode() check in XMake.cs to handle sidecar TaskHost processes
  • Updated documentation to reference new MSBUILDDEBUGONSTART=3 behavior
  • CodeQL security scan
  • 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

Original prompt

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.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Add check for sidecar taskhost in MSBUILDDEBUGONSTART Add MSBUILDDEBUGONSTART=3 to skip debugging TaskHost child processes Oct 20, 2025
Copilot finished work on behalf of JanProvaznik October 20, 2025 11:53
Copilot AI requested a review from JanProvaznik October 20, 2025 11:53
Copilot AI requested a review from JanProvaznik October 20, 2025 12:26
Copilot finished work on behalf of JanProvaznik October 20, 2025 12:26
@JanProvaznik JanProvaznik requested review from YuliiaKovalova and removed request for JanProvaznik October 20, 2025 12:31
Copilot AI requested a review from JanProvaznik October 20, 2025 12:40
Copilot finished work on behalf of JanProvaznik October 20, 2025 12:40
@JanProvaznik JanProvaznik marked this pull request as ready for review October 20, 2025 12:49
Copilot AI review requested due to automatic review settings October 20, 2025 12:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for MSBUILDDEBUGONSTART=3 to launch the debugger only for the main MSBuild process while skipping TaskHost processes. Key changes introduce a detection helper (IsInTaskHostNode), conditional debugger launch logic in XMake, a no-op case in OutOfProcTaskHost, and updated documentation plus a unit test.

  • Added IsInTaskHostNode() to identify TaskHost context.
  • Added case "3" handling in XMake.cs and OutOfProcTaskHost.cs.
  • Updated docs and added a single test for the new helper.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Shared/Debugging/DebugUtils.cs Adds IsInTaskHostNode() helper for node mode detection used by debugger logic.
src/MSBuild/XMake.cs Adds conditional debugger launch for value "3" skipping TaskHost nodes.
src/MSBuildTaskHost/OutOfProcTaskHost.cs Adds case "3" that intentionally skips launching debugger in TaskHost.
src/Build.UnitTests/BackEnd/DebugUtils_tests.cs Adds unit test covering false (central node) case of IsInTaskHostNode().
documentation/wiki/Building-Testing-and-Debugging-on-Full-Framework-MSBuild.md Documents new MSBUILDDEBUGONSTART=3 behavior.
documentation/wiki/Building-Testing-and-Debugging-on-.Net-Core-MSBuild.md Documents new MSBUILDDEBUGONSTART=3 usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants