Skip to content

Implement IBuildEngine3 Yield/Reacquire for out-of-proc task host#13

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/add-yielding-in-outofproctaskhost
Draft

Implement IBuildEngine3 Yield/Reacquire for out-of-proc task host#13
Copilot wants to merge 5 commits intomainfrom
copilot/add-yielding-in-outofproctaskhost

Conversation

Copy link

Copilot AI commented Dec 17, 2025

Context

The out-of-proc task host (OutOfProcTaskHostNode) had stub implementations for IBuildEngine3.Yield() and Reacquire() that did nothing. Tasks running in the out-of-proc host could not signal yield/reacquire operations to coordinate with the parent node.

Changes Made

Packet communication protocol:

  • Added TaskHostYield (0x16) and TaskHostReacquire (0x17) packet types
  • Created packet classes with standard deserialization factories
  • Implemented acknowledgment pattern: task host sends packet → parent echoes back → task host continues

OutOfProcTaskHostNode:

  • Yield() and Reacquire() now send packets to parent node and block on acknowledgment wait handles
  • Registered packet handlers to receive acknowledgment packets
  • Added _yieldAcknowledgedEvent and _reacquireAcknowledgedEvent with proper disposal

TaskHostTask:

  • Added HandleTaskHostYield() and HandleTaskHostReacquire() to process packets and send acknowledgments
  • Registered packet handlers for both packet types

Project files:

  • Added new packet classes to Microsoft.Build.csproj and MSBuild.csproj

Testing

  • Added unit test verifying Yield/Reacquire can be called without exceptions
  • Validated sample project builds successfully
  • All tests pass

Notes

This provides the foundation for tasks to yield control while performing long-running operations. Future work could extend this to support BuildProjectFilesInParallel from yielded tasks (currently returns an error), enabling environment switching and nested builds during yield.

Original prompt

figure out how to yield in outofproctaskhost (not net35 taskhost) so that we can switch environment there and build another project while yielded. implement ibuildengine3 callbacks


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits December 17, 2025 08:41
- Added TaskHostYield and TaskHostReacquire packet types (0x16, 0x17)
- Created packet classes for yield/reacquire communication
- Updated OutOfProcTaskHostNode to send yield/reacquire packets and wait for acks
- Updated TaskHostTask to handle and acknowledge yield/reacquire packets
- Added wait handles for yield and reacquire acknowledgments
- Properly dispose new wait handles on shutdown

Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
- Added TaskHostYield.cs and TaskHostReacquire.cs to Microsoft.Build.csproj
- Added TaskHostYield.cs and TaskHostReacquire.cs to MSBuild.csproj
- Build now succeeds without errors

Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
- Added TestYieldAndReacquire test to TaskHost_Tests.cs
- Test verifies that Yield() and Reacquire() can be called without exceptions
- Test passes successfully

Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
- Register TaskHostYield and TaskHostReacquire packet handlers in TaskHostTask
- Ensures proper packet routing and deserialization
- Addresses code review feedback

Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement yielding in outofproctaskhost for environment switching Implement IBuildEngine3 Yield/Reacquire for out-of-proc task host Dec 17, 2025
Copilot AI requested a review from JanProvaznik December 17, 2025 08:57
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.

2 participants