Skip to content

Resolve net task host params from the project properties#11543

Merged
YuliiaKovalova merged 26 commits into
dotnet:mainfrom
YuliiaKovalova:dev/ykovalova/use_project_props_for_sdk_resolution
Aug 15, 2025
Merged

Resolve net task host params from the project properties#11543
YuliiaKovalova merged 26 commits into
dotnet:mainfrom
YuliiaKovalova:dev/ykovalova/use_project_props_for_sdk_resolution

Conversation

@YuliiaKovalova

@YuliiaKovalova YuliiaKovalova commented Mar 5, 2025

Copy link
Copy Markdown
Member

based on: #11393

fixes: #11343

This PR contains logic that helps to resolve NetTaskHost execution params based on the project properties.
DOTNET_HOST_PATH => resolves path to dotnet.exe
RuntimeIdentifierGraphPath => gives the path to the sdk version resolved for the given project.

The values are passed to NodeProviderOutOfProcTaskHost by using taskHostParameters.
The exception is generated on attempt to use this functionality for sdk9 and lower.

For further flexibility the packet versioning support was added in NodePacketType.

MSBuild Packet Structure Overview

MSBuild's packet communication protocol supports versioning through an extended header mechanism. This document outlines the binary structure of packets with and without version information.

Basic Packet Format

Position Size (bytes) Description
0 1 Packet Type Byte
1-4 4 Packet Length (32-bit integer)
5+ Variable Packet Body

Packet Type Byte (Position 0) Bit Layout

Bits Purpose
0-5 Base packet type (values 0-63)
6 (0x40) Extended header flag - When set, indicates version information follows
7 Reserved for future use

NodePacketType Value Ranges

Range Purpose Examples
0x00-0x15 Core MSBuild packets (sequential) NodeConfiguration, BuildRequest, LogMessage
0x16-0x3B Reserved for future core packet expansion (38 values available)
0x3C-0x3F Server command packets ServerNodeBuildCommand, ServerNodeBuildResult

Key Design Principle: Clean bit separation ensures the extended header flag (bit 6) never conflicts with packet type values (0-63).

Implementation Notes

  • Bit field design: Lower 6 bits for packet type, bit 6 for extended header flag
  • No conflicts: Packet type values (0-63) never set bit 6
  • Server packet relocation: Moved from 0xF0-0xF3 to 0x3C-0x3F to avoid flag conflicts
  • Extensible: 38 unused packet type slots + bit 7 reserved for future use

Comment thread src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs Outdated
@YuliiaKovalova YuliiaKovalova marked this pull request as ready for review March 6, 2025 14:58
Comment thread src/Shared/TaskHostConfiguration.cs Outdated
Comment thread src/Shared/TaskHostConfiguration.cs Outdated
Comment thread src/Shared/NodeEndpointOutOfProcBase.cs Outdated
Comment thread src/Shared/NodeEndpointOutOfProcBase.cs Outdated
Comment thread src/Shared/INodePacket.cs Outdated
Comment thread src/Shared/CommunicationsUtilities.cs Outdated
Comment thread src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs Outdated
Comment thread src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs Outdated
@YuliiaKovalova YuliiaKovalova self-assigned this Jul 16, 2025

@baronfel baronfel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some very minor documentation nits as I was looking through. If I can understand this PR then you've done a great job making things easy to follow 🤣

Comment thread src/Framework/BinaryTranslator.cs Outdated
Comment thread src/Framework/BinaryTranslator.cs Outdated
Comment thread src/Framework/ITranslator.cs Outdated
Comment thread global.json
Comment thread src/Shared/INodePacket.cs Outdated
Comment thread global.json
Comment thread src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs Outdated
Comment thread src/Build/Resources/Constants.cs Outdated
Comment thread src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs Outdated
Comment thread src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs Outdated
Comment thread src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs Outdated
Comment thread src/Shared/CommunicationsUtilities.cs
Comment thread src/Shared/INodePacket.cs Outdated
Comment thread src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcBase.cs Outdated
Comment thread src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs Outdated
@YuliiaKovalova YuliiaKovalova force-pushed the dev/ykovalova/use_project_props_for_sdk_resolution branch from 7b6c601 to 1f121ae Compare August 5, 2025 15:27
Comment thread src/Shared/INodePacket.cs
@YuliiaKovalova YuliiaKovalova marked this pull request as ready for review August 7, 2025 13:53
Copilot AI review requested due to automatic review settings August 7, 2025 13:53
@YuliiaKovalova YuliiaKovalova requested a review from a team as a code owner August 7, 2025 13:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements support for resolving NET Task Host execution parameters from project properties to address issues with task host initialization. The solution introduces packet versioning infrastructure to enable protocol compatibility and adds logic to extract dotnet host path and SDK version information from project properties.

  • Adds packet versioning support with extended headers for MSBuild's communication protocol
  • Implements logic to resolve DOTNET_HOST_PATH and RuntimeIdentifierGraphPath from project properties
  • Refactors TaskHostConfiguration to use packet versioning instead of runtime parameters for AppDomain serialization decisions

Reviewed Changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Shared/INodePacket.cs Adds NodePacketTypeExtensions class with packet versioning utilities and reorganizes enum values
src/Shared/TaskHostConfiguration.cs Removes runtime parameter dependency, uses packet version for AppDomain config decisions
src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs Implements project property resolution for NET runtime host paths and SDK validation
src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs Adds logic to gather dotnet host path and MSBuild assembly path from project properties
src/Shared/NodeEndpointOutOfProcBase.cs Implements extended header reading and packet versioning in communication protocol
src/Framework/ITranslator.cs Adds PacketVersion property to ITranslator interface
src/Framework/BinaryTranslator.cs Implements PacketVersion property in both reader and writer translators
src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcBase.cs Implements extended header writing with packet versioning
src/Shared/CommunicationsUtilities.cs Updates handshake logic to support predefined tools directory parameter
src/Build/Resources/Constants.cs Adds constants for dotnet host path and MSBuild assembly path
src/Build/Instance/TaskFactories/TaskHostTask.cs Updates constructor signature and method calls for new parameter handling
src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs Updates parameter merging logic and method signatures
src/Build/Evaluation/IntrinsicFunctions.cs Updates method calls for new parameter handling
src/Build/Evaluation/Evaluator.cs Updates SDK resolution to use new constant names
src/Shared/BuildEnvironmentHelper.cs Removes unused NET-specific directory properties
src/Build/BackEnd/Node/OutOfProcServerNode.cs Fixes typo in comment
src/Build/BackEnd/Components/Communications/NodeLauncher.cs Updates comment for broader process types
src/UnitTests.Shared/RunnerUtilities.cs Reorders field declarations
src/Build.UnitTests/TestAssets/ExampleNetTask/TestNetTask/TestNetTask.csproj Adds SDK attribute to project
src/Build.UnitTests/NetTaskHost_E2E_Tests.cs Updates test to use new environment variables and error handling
src/Build.UnitTests/BackEnd/TaskHostConfiguration_Tests.cs Removes runtime parameter from test constructors
global.json Reorders SDK paths priority

Comment thread src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs Outdated
Comment thread src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs Outdated
Comment thread src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs Outdated
Comment thread src/Shared/INodePacket.cs
@YuliiaKovalova YuliiaKovalova force-pushed the dev/ykovalova/use_project_props_for_sdk_resolution branch from 074b8da to 8a1b057 Compare August 7, 2025 14:39
Comment thread src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs Outdated
Comment thread src/Build.UnitTests/TestAssets/ExampleNetTask/TestNetTask/global.json Outdated
Comment thread src/Build.UnitTests/NetTaskHost_E2E_Tests.cs Outdated
Comment thread src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs Outdated
Comment thread src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs Outdated
Comment thread src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs Outdated
Comment thread src/Build/Resources/Strings.resx

@rainersigwald rainersigwald left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Will look a the hard parts tomorrow 😅

Comment thread src/Build/Resources/Strings.resx Outdated
Comment thread src/Build/Resources/Strings.resx Outdated
@YuliiaKovalova YuliiaKovalova force-pushed the dev/ykovalova/use_project_props_for_sdk_resolution branch from 6dd942b to 1ac8408 Compare August 13, 2025 08:51

@rainersigwald rainersigwald left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall looking good to me!

Comment thread src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs
Comment thread src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs Outdated
Comment thread src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs Outdated
Comment thread src/Build/Resources/Strings.resx Outdated
Comment thread src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs Outdated
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.

Extract SDK path from SDK project to identify TaskHost

7 participants