Repository navigation
Mark WarnForInvalidProjectsTask as MSBuild-multithreadable - #7534
Merged
zivkan merged 2 commits intoJul 1, 2026
Merged
Conversation
…rk build The [MSBuildMultiThreadableTask] marker attribute only exists in Microsoft.Build.Framework 18.6 and later. The .NET (SDK) build of NuGet's MSBuild tasks gets it from the package, but the .NET Framework build compiles against the in-box MSBuild reference assemblies, which do not contain the type. This adds a self-defined compatibility shim (guarded by #if NETFRAMEWORK, in the Microsoft.Build.Framework namespace) so the shared task source can apply the marker without conditional compilation at every task. MSBuild detects the attribute by namespace and name only, so the shim is recognized by 18.6+ hosts and ignored by older ones. This is a prerequisite for migrating relative-path-resolving restore tasks to the multithreadable execution model. Co-authored-by: Copilot <[email protected]>
The task only reads its MSBuild item inputs (AllProjects/ValidProjects), computes the set difference, and logs a warning per invalid project through its own per-instance Log. It has no current-working-directory, environment-variable, ProcessStartInfo, or mutable-static usage and spawns no threads internally, so it is already thread-safe and needs only the [MSBuildMultiThreadableTask] marker - no IMultiThreadableTask/TaskEnvironment migration. Co-authored-by: Copilot <[email protected]>
Contributor
Author
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 dotnet/msbuild#14189
What
Mark
WarnForInvalidProjectsTaskwith[MSBuildMultiThreadableTask]so MSBuild can run it in-process during multithreaded builds (dotnet build -mt).Why attribute-only is safe
The task reads its item inputs (
AllProjects/ValidProjects), computes the set difference, and logs a warning per invalid project through its own per-instanceLog. It has:ProcessStartInfo/ process spawning,PathUtility.IsFileSystemCaseInsensitive, is a thread-safeLazy<bool>derived from the OS (machine-invariant),So it is already thread-safe and needs only the marker — no
IMultiThreadableTask/TaskEnvironment. Per the multithreadable-task guidance, an attribute-only migration with no file/env/process/static interaction has nothing meaningful to assert, so no new test is added.The
[MSBuildMultiThreadableTask]attribute polyfill for the .NET Framework build is included as a separate commit.