Repository navigation
Mark GetRestoreProjectStyleTask as MSBuild-multithreadable - #7537
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 reads its item/property inputs and produces the project style. Its only file-system access (probing for packages.config via BuildTasksUtility.GetProjectRestoreStyle -> ProjectHasPackagesConfigFile -> GetPackagesConfigFilePath) is File.Exists on Path.Combine(MSBuildProjectDirectory, ...). MSBuildProjectDirectory is the [Required] always-absolute $(MSBuildProjectDirectory), so the probe never resolves against the current directory. There is no environment-variable, ProcessStartInfo, Path.GetFullPath, or mutable-static usage, so the task is already thread-safe and needs only the [MSBuildMultiThreadableTask] marker - no IMultiThreadableTask/TaskEnvironment migration. Co-authored-by: Copilot <[email protected]>
Contributor
Author
zivkan
enabled auto-merge (squash)
July 1, 2026 23:20
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#14184
What
Mark
GetRestoreProjectStyleTaskwith[MSBuildMultiThreadableTask]so MSBuild can run it in-process during multithreaded builds (dotnet build -mt).Why attribute-only is safe
The task reads its item/property inputs and produces the project style outputs. Call-chain audit (
Execute->BuildTasksUtility.GetProjectRestoreStyle->ProjectHasPackagesConfigFile->GetPackagesConfigFilePath):File.Exists(Path.Combine(MSBuildProjectDirectory, "packages.config")).MSBuildProjectDirectoryis the[Required], always-absolute$(MSBuildProjectDirectory), so the probe never resolves against the current directory.ProcessStartInfo, noPath.GetFullPath, no mutable static state.The
[MSBuildMultiThreadableTask]attribute polyfill for the .NET Framework build is included as a separate commit.