Conversation
Contributor
Author
Member
|
Probably fine, need to merge the other first. |
This was referenced Jun 26, 2026
4 tasks
nkolev92
reviewed
Jun 30, 2026
MSBuild 18.6 can run tasks in-process during parallel builds (dotnet build -mt / dotnet restore). Tasks opt in by carrying the [MSBuildMultiThreadableTask] marker attribute (Microsoft.Build.Framework). This applies the marker to the 12 NuGet restore tasks that are already thread-safe: they only read MSBuild item inputs and produce outputs, with no current-working-directory, environment-variable, ProcessStartInfo, or mutable-static usage. Tasks that resolve relative paths (e.g. GetRestoreProjectReferencesTask, GetRestoreSolutionProjectsTask) are intentionally left out; they need the TaskEnvironment migration first. To avoid conditional compilation at every task, a self-defined compatibility shim of the attribute is added for the .NET Framework build only (Common/MSBuildMultiThreadableTaskAttribute.cs, guarded by #if NETFRAMEWORK). The .NET (SDK) build uses the real attribute from the Microsoft.Build.Framework 18.6.3 package. MSBuild detects this attribute by namespace and name only (ignoring the defining assembly), so the shim is recognized by 18.6+ hosts and ignored by older ones. The shim is also compiled into NuGet.Build.Tasks.Pack because it shares GetProjectTargetFrameworksTask. Multithreaded mode is currently experimental and CLI-only; Visual Studio still runs tasks out of process, so the marker is a safe no-op there today. Tasks marked: GetRestoreDotnetCliToolsTask, GetProjectTargetFrameworksTask, GetRestorePackageReferencesTask, GetCentralPackageVersionsTask, GetRestorePackageDownloadsTask, GetRestoreFrameworkReferencesTask, GetRestoreNuGetAuditSuppressionsTask, GetRestorePrunePackageReferencesTask, CheckForDuplicateNuGetItemsTask, NuGetMessageTask, GetGlobalPropertyValueTask, GetReferenceNearestTargetFrameworkTask. Reference: https://learn.microsoft.com/visualstudio/msbuild/update-task-multithreaded Part of NuGet/Home#14958. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
JanProvaznik
force-pushed
the
dev-janprovaznik-multithreadable-restore-tasks
branch
from
July 1, 2026 08:57
c595edd to
a87a270
Compare
zivkan
approved these changes
Jul 1, 2026
zivkan
enabled auto-merge (squash)
July 1, 2026 21:03
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.
Bug
Fixes: addresses the trivial case of part 3 NuGet/Home#14958
Description
These tasks are stateless so they can be used in multithreaded msbuild execution without changes.
polyfill the attribute to net472 where we're not consuming the new MSBuild API
on top of #7508
PR Checklist
Added testsLink to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.