Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link

Copilot AI commented Dec 3, 2025

Fixes dotnet#12863

Context

TaskHost (OutOfProcTaskHostNode) implements IBuildEngine10 but lacks callback support. When tasks in TaskHost call IsRunningMultipleNodes, RequestCores/ReleaseCores, or Yield/Reacquire, builds fail with MSB5022 or NotImplementedException. This blocks multithreaded builds with -mt mode when MSBUILDFORCEALLTASKSOUTOFPROC=1.

Changes Made

Packet Infrastructure

  • Added 8 new packet types to INodePacket.cs enum (0x20-0x27 range)
  • Created 6 packet classes for bidirectional request/response communication
  • Implemented request correlation using unique IDs with TaskCompletionSource<INodePacket>

Phase 1: IsRunningMultipleNodes

  • TaskHostQueryRequest/TaskHostQueryResponse packets
  • Updated OutOfProcTaskHostNode.IsRunningMultipleNodes to forward query to parent
  • TaskHostTask handles request and returns parent's IBuildEngine2.IsRunningMultipleNodes value

Phase 2: RequestCores/ReleaseCores

  • TaskHostResourceRequest/TaskHostResourceResponse packets
  • Replaced NotImplementedException with forwarding to parent's IBuildEngine9
  • Returns actual cores granted from scheduler

Phase 3: Yield/Reacquire

  • TaskHostYieldRequest/TaskHostYieldResponse packets
  • Replaced silent no-ops with forwarding to parent's IBuildEngine3
  • Enables actual yielding for scheduler optimization

Threading Model

  • Task thread sends request and blocks on TaskCompletionSource.Task.Wait(timeout) (60s default)
  • Main thread receives response via IPC and completes TCS to unblock task thread
  • Timeout handling falls back to safe defaults

Testing

  • 19 new unit tests covering packet serialization and round-trip scenarios
  • All 98 existing TaskHost tests pass with 0 regressions
  • Validated build succeeds and bootstrap environment works correctly

Notes

Phase 4 (BuildProjectFile* callbacks) deferred - requires complex ITaskItem[] serialization and recursive build handling. Current implementation provides proven pattern for future extension.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dnceng.pkgs.visualstudio.com
    • Triggering command: /home/REDACTED/work/msbuild/msbuild/artifacts/bin/bootstrap/core/dotnet dotnet test src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj --filter FullyQualifiedName~TaskHostQueryPackets -v quiet (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

create a tested implementation from this spec dotnet#12868


💡 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 3, 2025 17:09
- Add TaskHostQueryRequest and TaskHostQueryResponse packet types
- Implement request/response infrastructure in OutOfProcTaskHostNode
- Add handler in TaskHostTask to forward queries to parent node
- Update IsRunningMultipleNodes property to use callback mechanism

Co-authored-by: JanProvaznik <[email protected]>
- Add TaskHostQueryPackets_Tests.cs with comprehensive tests
- Test packet serialization/deserialization
- Test constructors and properties
- All tests pass successfully

Co-authored-by: JanProvaznik <[email protected]>
- Add TaskHostResourceRequest and TaskHostResourceResponse packet types
- Implement forwarding in OutOfProcTaskHostNode.cs
- Add handler in TaskHostTask.cs to forward to parent IBuildEngine9
- Add comprehensive unit tests
- All tests pass successfully

Co-authored-by: JanProvaznik <[email protected]>
- Add TaskHostYieldRequest and TaskHostYieldResponse packet types
- Implement forwarding in OutOfProcTaskHostNode.cs
- Add handler in TaskHostTask.cs to forward to parent IBuildEngine3
- Add comprehensive unit tests
- All tests pass successfully

Co-authored-by: JanProvaznik <[email protected]>
Copilot AI changed the title [WIP] Create tested implementation from spec Implement TaskHost IBuildEngine callback support (Phases 1-3) Dec 3, 2025
Copilot AI requested a review from JanProvaznik December 3, 2025 17:31
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.

TaskHost Does Not Support Critical IBuildEngine Callbacks

2 participants