Repository navigation
Handle cross-runtime task parameter binding - #14913
Conversation
cd55f98 to
b6e4dfd
Compare
Preserve unresolved parameter shapes for worker expansion and perform final conversion in a compatible .NET task host. Keep old-host behavior and custom item output metadata without changing the wire protocol. Co-authored-by: Copilot <[email protected]> Copilot-Session: 0308e243-44f8-4ce1-b36f-e206f0fa4cd8
f565286 to
665d2de
Compare
Keep required empty enum vectors compatible with older task hosts and preserve null path-array elements through existing transport. Cover metadata-only binding, unsupported array ranks, and output property semantics. Co-authored-by: Copilot <[email protected]> Copilot-Session: 513be76c-06ca-4701-b762-a0a230a9f596
Review — WHOLE PR #14913 · 17 files, +980/−28Methodology: portable core + dotnet/msbuild expert-reviewer · Panel: GPT-5.6 Sol lead + GPT-5.6 Terra behavioral + GPT-5.5 red-team · 24/24 dimensions evaluated Verdict: 🟡 COMMENT — address findings (non-blocking) — 0 blocking, 0 major, 3 moderate, 1 nit · 19 of 24 evaluated dimensions clean The previously identified blocking and major issues are fixed in Optional, non-blocking observations (4)🟡 MODERATE · Performance — Runtime type-resolution misses are repeated for every invocation. · TaskExecutionHost.cs:1582
🟡 MODERATE · Error Messages — MSB4069 can report the surrogate rather than the declared parameter type. · TaskExecutionHost.cs:1607–1610
🟡 MODERATE · Logging & Diagnostics — Ordinary conversion failures still use fatal task-crash logging. · OutOfProcTaskAppDomainWrapperBase.cs:395–401
⚪ NIT · Documentation — The transport comment still says custom value-type inputs are unsupported. · TaskParameter.cs:503
✅ Clean (19)✅ Backward compatibility — required empty enum vectors and existing Int32 transport remain supported. |
There was a problem hiding this comment.
🟡 Changes recommended
The new host-conversion capability probe in SupportsTaskParameterConversion can compute an invalid probe path when MSBuildAssemblyPath is not a directory, causing false “old host” detection and incorrect MSB4069 failures.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR hardens task parameter binding when a .NET Framework MSBuild worker evaluates Runtime="NET" tasks whose parameter types aren’t resolvable in the worker runtime. It keeps reflected parameter metadata usable (no null holes), preserves wire-shape for values/items across the task-host boundary, and defers final type conversion to the .NET task host when necessary.
Changes:
- Makes
LoadedType.Propertiesresilient to unresolvable parameter types and adds a bounded metadata-signature fallback to classify supported scalar/array shapes for expansion. - Adds host-side conversion for deferred values (via
ValueTypeParser) and preservesITaskItem-shaped outputs (including null outputs) usingTaskParameterwire tags. - Adds capability detection for “conversion-aware” hosts and expands unit/E2E coverage for cross-runtime binding, null-preserving value-type arrays, and enum-array legacy transport.
File summaries
| File | Description |
|---|---|
| src/Shared/UnitTests/TaskParameter_Tests.cs | Adds coverage for null-preserving ValueTypeArray transport and legacy Int32 enum-array transport. |
| src/Shared/TaskParameter.cs | Adds CreateForTaskOutput and preserves null elements when serializing ValueTypeArray. |
| src/Shared/TaskHostTaskComplete.cs | Avoids double-wrapping values already serialized as TaskParameter. |
| src/MSBuild/OutOfProcTaskAppDomainWrapperBase.cs | Converts deferred parameter values on the .NET host side and preserves null task outputs via TaskParameter. |
| src/Framework/TaskPropertyInfo.cs | Allows internal mutation of IsValueTypeOutputParameter for metadata-load scenarios. |
| src/Framework/ReflectableTaskPropertyInfo.cs | Carries unresolved-type and expansion-type hints through reflection-backed task property info. |
| src/Framework/Microsoft.Build.Framework.csproj | Adds System.Reflection.Metadata dependency for .NET Framework builds. |
| src/Framework/Loader/LoadedType.cs | Keeps properties dense and classifies expansion types (including via metadata signature parsing) for unresolved types. |
| src/Framework.UnitTests/LoadedType_Tests.cs | Adds boundedness tests for signature classification. |
| src/Build/Instance/TaskFactories/TaskHostTask.cs | Tracks whether the NET task host supports deferred-parameter conversion; preserves TaskParameter outputs. |
| src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs | Avoids crashes on unresolved types, defers conversion to host when needed, and improves type-name reporting in diagnostics. |
| src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs | Adds host capability probing (metadata-based) and keys task hosts by conversion capability. |
| src/Build.UnitTests/TestAssets/ExampleNetTask/TestNetTask/TestParameterBinding.proj | Adds a test project to validate binding/escaping and output round-trips. |
| src/Build.UnitTests/TestAssets/ExampleNetTask/ExampleTask/ExampleTask.cs | Expands the example NET task with enums, path types, and typed/custom item outputs. |
| src/Build.UnitTests/NetTaskHost_E2E_Tests.cs | Adds end-to-end tests for cross-runtime parameter binding and old-host rejection behavior. |
| src/Build.UnitTests/BackEnd/TaskExecutionHost_Tests.cs | Adds coverage for old-host behaviors and null-preserving value-type-array output semantics. |
| src/Build.UnitTests/BackEnd/TaskBuilderTestTask.cs | Adds an enum-array parameter hook for task-host binding tests. |
Review details
- Files reviewed: 17/17 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
baronfel
left a comment
There was a problem hiding this comment.
Have a couple notes, and my brain is a little twisted, but this looks like it's going in the right direction!
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
rainersigwald
left a comment
There was a problem hiding this comment.
I would really appreciate a clear summary of how all of the task parameter analysis and passing works. Can you derive a doc for that?
|
@rainersigwald I will write here a high-level summary and send you the document. So, the PR does this:
Before deferring conversion, MSBuild checks whether the selected host supports it. Older hosts retain their compatible paths; values requiring unsupported conversion are rejected. |
Keep raw signature inspection in the engine while preserving unresolved parameter expansion and old-host compatibility. Co-authored-by: Copilot App <[email protected]>
JanProvaznik
left a comment
There was a problem hiding this comment.
I would really appreciate conceptual explanation of the changes in the PR description, I think it's a bit wasteful for me to need to load the full context of the original issue and diff to an agent to get to what is this change doing.
Retain recoverable declared type identities separately from expansion surrogates so unsupported parameter diagnostics report the original type. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 43c02ab6-cf09-483b-a2dd-0293e1bc849e
Co-authored-by: Copilot App <[email protected]>
Exercise TaskBuilderTestTask from the Core test assembly through Framework MSBuild's NET task host, asserting successful binding and preservation of item identity, full path, and metadata. This captures the desired behavior without changing the currently incomplete typed-item binding implementation. Co-authored-by: Copilot App <[email protected]>
rainersigwald
left a comment
There was a problem hiding this comment.
Looks like this doesn't support ITaskItem<FileInfo> and friends. Just pushed a test that should exercise that.
Gate cross-runtime parameter conversion on the task host protocol version and preserve typed task-item binding across host boundaries. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 43c02ab6-cf09-483b-a2dd-0293e1bc849e
rainersigwald
left a comment
There was a problem hiding this comment.
My comments aren't blocking so removing the block.
|
@rainersigwald "not blocking" as in this should be merged now at the RC2 deadline time or tomorrow after branching? |
Group host acquisition options, use structured launch identities, and clarify task parameter conversion state. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 43c02ab6-cf09-483b-a2dd-0293e1bc849e
|
/backport to vs18.12 |
|
Started backporting to |
Backport of #14913 to vs18.12 ### Summary Prior to this change, tasks that use strongly-typed parameters would fail when run in a `Runtime="NET"` taskhost. ### Customer Impact Blocks the use of strongly-typed task parameters in .NET-only tasks, which is an increasing percentage of first-party tasks and an intended migration target. ### Regression? No, this was a bug in the new implementation of strongly-typed task parameters. ### Testing Unit tests and new end-to-end scenario testing for strongly-typed parameters in a .NET taskhost. ### Risk Low; unblocks migration work but shouldn't affect any task that doesn't use the new feature. Co-authored-by: Aleš Prokop <[email protected]> Co-authored-by: Copilot <[email protected]>
Fixes #14680
Context
.NET Framework MSBuild cannot always resolve parameter types belonging to a
Runtime="NET"task. This could leave null property entries or pass a null type into parameter validation. The worker now preserves the expansion shape and leaves final conversion to a compatible .NET task host.Changes Made
LoadedType.Propertiesdense and added bounded metadata-signature fallback for supported scalar and array shapes.TaskEnvironmentpath rooting; added host-side conversion throughValueTypeParser.ITaskItemscalar, array, and null outputs using existingTaskParameterwire tags.MSB4069before sending unsupported values, while retaining empty optional parameters and legacy-compatible Int32 enum arrays.System.Reflection.Metadatadependency forMicrosoft.Build.Frameworkon .NET Framework.Testing
MSBUILDFORCEMULTITHREADED=1: 0 warnings, 0 errors.PropertySignatureClassifierIsBoundedcovered excessive nesting and malformed counts on net472 and net11.NetTaskHost_BindsParametersUnavailableInWorkerRuntimecovered enum inputs, paths and escaping, value outputs, and custom item/null outputs with metadata.NetTaskHost_DoesNotSendConvertedParametersToOldHostcovered old-host rejection.OldNetTaskHostAllowsOptionalConversionParameterWhenExpansionIsEmptycovered empty scalar and vector inputs.OldNetTaskHostRejectsRequiredEmptyConversionArraycovered required-array rejection.OldNetTaskHostKeepsLegacyInt32EnumArrayTransportandInt32EnumArrayUsesLegacyPrimitiveArrayTransportcovered existing enum-vector compatibility.AbsolutePathParameterandAbsolutePathArrayParametertransport tests passed.Result: 13 selected tests passed, 0 failed, 0 skipped.
Notes