Fix BuildCheck CustomCheck E2E tests (NU1605 restore downgrade)#14137
Merged
baronfel merged 7 commits intoJun 25, 2026
Merged
Conversation
…-> Utilities.Core dependency Binding ITaskItem<T>/TaskItem<T> task parameters reflected over the public Microsoft.Build.Utilities.TaskItem<T>, which required a ProjectReference from Microsoft.Build to Microsoft.Build.Utilities. That made the Microsoft.Build NuGet package depend on Microsoft.Build.Utilities.Core, triggering an NU1605 package-downgrade restore failure in the BuildCheck CustomCheck end-to-end tests. Bind via an engine-internal ITaskItem<T> implementation (StronglyTypedTaskItem<T>) for the interface case, and via the declared concrete type reflectively otherwise, so Microsoft.Build no longer references Microsoft.Build.Utilities.Core. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
baronfel
requested changes
Jun 23, 2026
- Instantiate StronglyTypedTaskItem<T> directly via a switch over the closed set of supported value types (FileInfo/DirectoryInfo/AbsolutePath) instead of MakeGenericType/GetConstructor/Invoke. This keeps the constructions statically visible (better for trimming/AOT) and flows type information instead of using heavy reflection. - Make StronglyTypedTaskItem.cs #nullable enable and the constructor internal (no longer located via reflection). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Define the closed set of ITaskItem<T>/TaskItem<T> value types once in
TaskItemTypeDetector.IsSupportedValueType. Type detection and StronglyTypedTaskItem.IsPathLikeType
now defer to it, removing the duplicated {AbsolutePath, FileInfo, DirectoryInfo} lists. The
reflection-free construction switch documents that it must mirror that predicate and guards drift
with a final throw.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…+ comments - Reject the concrete public Microsoft.Build.Utilities.TaskItem<T> as a task INPUT parameter (IsValidScalarInputParameter/IsValidVectorInputParameter exclude it from the value-type branch), so authors get the clear UnsupportedTaskParameterTypeError diagnostic instead of an opaque cast failure. Input binding now routes only the interface ITaskItem<T>; the concrete type stays supported for OUTPUTs via name-based detection. - Rename IsSupportedValueType -> IsSupportedPathLikeType (FileInfo/DirectoryInfo are reference types, not value types) and soften the "single source of truth" comments to reflect that the engine construction switch must be kept in sync with (not "defer to") the predicate. - Add tests: concrete-input rejection + interface-still-valid in the verifier, and a drift guard asserting every supported type has a construction branch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
baronfel
pushed a commit
that referenced
this pull request
Jun 25, 2026
Fixes #14163 Fixes BuildCheck tests in pipeline. Investigation flow -> found [log](https://dev.azure.com/dnceng-public/_apis/resources/Containers/54226185/CoreOnLinux%20build%20logs?itemPath=CoreOnLinux%20build%20logs%2FMicrosoft.Build.BuildCheck.UnitTests_net10.0_x64.log) for pipeline failure. From this log I found out that the BuildCheck `CustomCheck*` end-to-end tests fail at restore with **NU1605** (package downgrade of `Microsoft.Build.Framework`), so `-check` never runs and the expected diagnostics are never emitted. **Root cause:** `Microsoft.Build` had gained a `ProjectReference` to `Microsoft.Build.Utilities`, so the `Microsoft.Build` NuGet package declared a dependency on `Microsoft.Build.Utilities.Core`. During the `CustomCheck` test-package restore that dependency resolved to an older preview and was flagged as a downgrade-as-error. **Fix:** move the public `TaskItem<T>` from `Microsoft.Build.Utilities` into `Microsoft.Build.Framework` so it is a single shared type usable from both the engine and Utilities. This removes the `Microsoft.Build` -> `Microsoft.Build.Utilities.Core` dependency without duplicating the type. A small internal `MutableTaskItem` backs the value constructor (Framework cannot reference `Utilities.TaskItem`); it is nullable-enabled and stores metadata in an `ImmutableDictionary` seeded from the shared `ImmutableDictionaryExtensions.EmptyMetadata` (case-insensitive comparer), matching the existing `Utilities.TaskItem` behavior. No product behavior change. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 #14163
Fixes BuildCheck tests in pipeline. Investigation flow -> found log for pipeline failure. From this log I found out that the BuildCheck
CustomCheck*end-to-end tests fail at restore with NU1605 (package downgrade ofMicrosoft.Build.Framework), so-checknever runs and the expected diagnostics are never emitted.Root cause:
Microsoft.Buildhad gained aProjectReferencetoMicrosoft.Build.Utilities, so theMicrosoft.BuildNuGet package declared a dependency onMicrosoft.Build.Utilities.Core. During theCustomChecktest-package restore that dependency resolved to an older preview and was flagged as a downgrade-as-error.Fix: move the public
TaskItem<T>fromMicrosoft.Build.UtilitiesintoMicrosoft.Build.Frameworkso it is a single shared type usable from both the engine and Utilities. This removes theMicrosoft.Build->Microsoft.Build.Utilities.Coredependency without duplicating the type. A small internalMutableTaskItembacks the value constructor (Framework cannot referenceUtilities.TaskItem); it is nullable-enabled and stores metadata in anImmutableDictionaryseeded from the sharedImmutableDictionaryExtensions.EmptyMetadata(case-insensitive comparer), matching the existingUtilities.TaskItembehavior. No product behavior change.