Skip to content

Migrate GetRestoreSolutionProjectsTask to the multithreadable model - #7533

Merged
zivkan merged 3 commits into
NuGet:devfrom
OvesN:veronikao/migrate-GetRestoreSolutionProjectsTask-to-mt
Jul 3, 2026
Merged

zivkan merged 3 commits into
NuGet:devfrom
OvesN:veronikao/migrate-GetRestoreSolutionProjectsTask-to-mt

Conversation

@OvesN

@OvesN OvesN commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes dotnet/msbuild#14187

What & why

MSBuild 18.6 can run tasks in-process during multithreaded builds (dotnet build -mt). GetRestoreSolutionProjectsTask resolved relative project paths with Path.GetFullPath, which depends on the process current directory — incorrect when the task shares a long-lived process. This migrates it to the multithreadable model.

Changes

  • Mark the task [MSBuildMultiThreadableTask]; implement IMultiThreadableTask on the .NET (SDK) build.
  • Resolve relative paths via TaskEnvironment.GetAbsolutePath (project directory) instead of Path.GetFullPath (current directory). The .NET Framework build keeps the original behavior.
  • Add the [MSBuildMultiThreadableTask] attribute polyfill for the .NET Framework build (separate commit) so the marker compiles against the in-box MSBuild facade.
  • Add a net10.0 test asserting relative inputs resolve against the project directory, not the current directory.

OvesN and others added 2 commits July 1, 2026 00:18
…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]>
Mark the task with [MSBuildMultiThreadableTask] and, on the .NET (SDK) build, implement
IMultiThreadableTask. Relative project paths are now resolved with TaskEnvironment.GetAbsolutePath
(rooted at the project directory) instead of Path.GetFullPath (rooted at the process current
directory), so the task is correct when MSBuild runs it in-process during multithreaded builds.
The .NET Framework build keeps the original Path.GetFullPath behavior. Adds a net10.0 test asserting
relative inputs resolve against the project directory rather than the current directory.

Co-authored-by: Copilot <[email protected]>
@OvesN
OvesN requested a review from a team as a code owner June 30, 2026 22:43
@OvesN
OvesN requested review from kartheekp-ms and zivkan June 30, 2026 22:43
@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

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 GetRestoreSolutionProjectsTask in NuGet

4 participants