Skip to content

Only mark GetRestoreProjectReferencesTask as multithreadable on .NET - #7538

Merged
zivkan merged 1 commit into
NuGet:devfrom
OvesN:veronikao/GetRestoreProjectReferencesTask-mt-attribute-net-only
Jul 3, 2026
Merged

zivkan merged 1 commit into
NuGet:devfrom
OvesN:veronikao/GetRestoreProjectReferencesTask-mt-attribute-net-only

Conversation

@OvesN

@OvesN OvesN commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Bug

Fixes: N/A - engineering change

Description

GetRestoreProjectReferencesTask carries the [MSBuildMultiThreadableTask] marker, but that guarantee only holds on .NET.

  • On .NET, the task resolves each project path with TaskEnvironment.GetAbsolutePath, which anchors relative paths to the task's project directory. That is safe under multithreaded (in-process) execution.
  • On .NET Framework, there is no TaskEnvironment, so the task falls back to Path.GetFullPath(combinedPath). When ParentProjectPath (and therefore combinedPath) is relative, Path.GetFullPath resolves it against the process-wide current working directory. Two task instances running concurrently in one process can then observe each other's working-directory state and produce incorrect paths.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@dotnet-policy-service dotnet-policy-service Bot added the Community PRs created by someone not in the NuGet team label Jul 2, 2026
On .NET Framework the task has no TaskEnvironment and resolves project paths
with Path.GetFullPath, which anchors relative paths to the process working
directory and is not safe under multithreaded execution. Guard the
[MSBuildMultiThreadableTask] marker with #if !NETFRAMEWORK so the task only
advertises multithread-safety on .NET, where TaskEnvironment.GetAbsolutePath
resolves paths against the task's project directory.

Co-authored-by: Copilot <[email protected]>
@OvesN
OvesN force-pushed the veronikao/GetRestoreProjectReferencesTask-mt-attribute-net-only branch from df66187 to 260d482 Compare July 2, 2026 11:52
@OvesN
OvesN marked this pull request as ready for review July 2, 2026 11:52
@OvesN
OvesN requested a review from a team as a code owner July 2, 2026 11:52
@OvesN
OvesN requested review from Nigusu-Allehu and jebriede July 2, 2026 11:52
@OvesN

OvesN commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@nkolev92 @zivkan ptal

@nkolev92 nkolev92 self-assigned this Jul 2, 2026
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.

3 participants