Add HostServices support in Out-of-Process Task Host#12753
Merged
YuliiaKovalova merged 31 commits intomainfrom Jan 9, 2026
Merged
Add HostServices support in Out-of-Process Task Host#12753YuliiaKovalova merged 31 commits intomainfrom
YuliiaKovalova merged 31 commits intomainfrom
Conversation
This reverts commit 2992c64.
Removed unused error handling code and associated methods.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables out-of-process task hosts to access host objects registered via HostServices.RegisterHostObject(). Previously, tasks running in out-of-proc task hosts couldn't access these host objects because the necessary information wasn't transmitted to the task host process.
Key changes:
- Introduced packet version negotiation during handshake, incrementing PacketVersion from 1 to 2
- Added
HostServicesandtargetNamefields toTaskHostConfigurationwith conditional serialization - Propagated
HostServicesandtargetNamethrough the task execution call chain - Enhanced
HostServices.GetAnyMatchingMonikerNameOrITaskHost()to handle fully-qualified task names
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Shared/TaskHostConfiguration.cs | Added HostServices and targetName fields with conditional serialization based on negotiated packet version |
| src/Shared/NodeEndpointOutOfProcBase.cs | Implemented PacketVersion exchange during handshake and updated to use NegotiatedPacketVersion |
| src/Shared/INodePacket.cs | Incremented PacketVersion to 2 and added GetNegotiatedPacketVersion helper method |
| src/Shared/CommunicationsUtilities.cs | Enhanced handshake protocol to read and negotiate packet versions between nodes |
| src/MSBuild/OutOfProcTaskHostNode.cs | Passed targetName and HostServices to task execution wrapper |
| src/MSBuild/OutOfProcTaskAppDomainWrapperBase.cs | Added logic to resolve and set host objects from HostServices |
| src/Build/Instance/TaskFactories/TaskHostTask.cs | Propagated HostServices through task initialization |
| src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs | Added HostServices parameter to CreateTaskInstance |
| src/Build/Instance/HostServices.cs | Enhanced to handle fully-qualified task names by falling back to short name lookup |
| src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs | Added HostServices support in task initialization |
| src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs | Passed HostServices from build request to task execution host |
| src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcBase.cs | Updated to track and propagate negotiated packet version through NodeContext |
| src/Build.UnitTests/BackEnd/TaskHostConfiguration_Tests.cs | Updated all test cases to include new parameters (null HostServices and targetName) |
| src/Build.UnitTests/BackEnd/TaskExecutionHost_Tests.cs | Updated test initialization calls with null HostServices parameter |
| src/Build.UnitTests/BackEnd/AssemblyTaskFactory_Tests.cs | Updated all CreateTaskInstance calls with null HostServices parameter |
| src/MSBuild/MSBuild.csproj | Added blank line at end of file |
| src/Build/Instance/RunningObjectTable.cs | Removed BOM character from file |
| src/Framework/ITranslator.cs | Renamed PacketVersion to NegotiatedPacketVersion with updated documentation |
| src/Framework/BinaryTranslator.cs | Renamed PacketVersion to NegotiatedPacketVersion property |
src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcBase.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
rainersigwald
approved these changes
Jan 9, 2026
This was referenced Jan 10, 2026
YuliiaKovalova
added a commit
that referenced
this pull request
Jan 20, 2026
In scope of #12753 support for translating HostServices in Out of Proc Task Host was added, but limited to NET task host. This change removes this limitation.
YuliiaKovalova
added a commit
that referenced
this pull request
Feb 3, 2026
JanProvaznik
pushed a commit
to JanProvaznik/msbuild
that referenced
this pull request
Feb 25, 2026
Attempt 2 for dotnet#13089 In scope of dotnet#12753 support for translating HostServices in Out of Proc Task Host was added, but limited to NET task host. This change removes this limitation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: #11510
Summary
This PR enables out-of-process task hosts to properly resolve host objects by passing HostServices and the target name through the task host communication protocol. Previously, tasks running in out-of-proc task hosts could not access host objects registered via HostServices.RegisterHostObject() because this information was not transmitted to the task host process.
Changes
Protocol Versioning & Negotiation
Introduced packet version negotiation during the handshake between parent and child nodes,
Child nodes now send their supported PacketVersion during handshake, allowing backward/forward-compatible communication between different MSBuild versions
Incremented PacketVersion from 1 to 2 to support the new fields - HostServices, targetName and project file path
Both new fields are conditionally serialized only when NegotiatedPacketVersion >= 2.
Updated OutOfProcTaskAppDomainWrapperBase.ExecuteTask() to accept and use HostServices and targetName
Task host now calls _hostServices.GetHostObject(taskFile, targetName, taskName) to resolve the host object before task execution
Fixed HostServices.GetAnyMatchingMonikerNameOrITaskHost() to handle fully-qualified task names by falling back to short name lookup
Handshake Flow (Before vs After)
Before
After