Skip to content

Mark WarnForInvalidProjectsTask as MSBuild-multithreadable - #7534

Merged
zivkan merged 2 commits into
NuGet:devfrom
OvesN:veronikao/migrate-WarnForInvalidProjectsTask-to-mt
Jul 1, 2026
Merged

zivkan merged 2 commits into
NuGet:devfrom
OvesN:veronikao/migrate-WarnForInvalidProjectsTask-to-mt

Conversation

@OvesN

@OvesN OvesN commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes dotnet/msbuild#14189

What

Mark WarnForInvalidProjectsTask with [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-instance Log. It has:

  • no current-working-directory use or relative-path resolution,
  • no environment variables,
  • no ProcessStartInfo / process spawning,
  • no mutable static state — the only static it reaches, PathUtility.IsFileSystemCaseInsensitive, is a thread-safe Lazy<bool> derived from the OS (machine-invariant),
  • no internally spawned threads.

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.

OvesN and others added 2 commits July 1, 2026 00:49
…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]>
@OvesN
OvesN requested a review from a team as a code owner June 30, 2026 22:51
@OvesN
OvesN requested review from Nigusu-Allehu and nkolev92 June 30, 2026 22:51
@dotnet-policy-service dotnet-policy-service Bot added the Community PRs created by someone not in the NuGet team label Jun 30, 2026
@OvesN

OvesN commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@nkolev92 @zivkan ptal

@zivkan zivkan 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.

@OvesN in the future please use/keep our PR template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community PRs created by someone not in the NuGet team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Multithreaded] Migrate WarnForInvalidProjectsTask in NuGet

3 participants