Skip to content

Migrate GetReferenceAssemblyPaths task to TaskEnvironment API#13495

Merged
OvesN merged 7 commits intodotnet:mainfrom
OvesN:dev/veronikao/dev/veronikao/migrate-GetReferenceAssemblyPaths-task-to-Task-Environment-API
Apr 14, 2026
Merged

Migrate GetReferenceAssemblyPaths task to TaskEnvironment API#13495
OvesN merged 7 commits intodotnet:mainfrom
OvesN:dev/veronikao/dev/veronikao/migrate-GetReferenceAssemblyPaths-task-to-Task-Environment-API

Conversation

@OvesN
Copy link
Copy Markdown
Contributor

@OvesN OvesN commented Apr 7, 2026

Fixes #13494

Context

The GetReferenceAssemblyPaths task was made thread-safe for multithreaded MSBuild execution.

Changes Made

GetReferenceAssemblyPaths.cs

  • Replaced static bool? s_net35SP1SentinelAssemblyFound with static readonly Lazy<bool> using LazyThreadSafetyMode.PublicationOnly to ensure thread-safe initialization while preserving retry-on-failure behavior.
  • Routed path resolution through TaskEnvironment.GetAbsolutePath().

Testing

GetReferencePaths_Tests.cs

  • TestRelativeRootPathProducesSameResultAsAbsolute — runs the task twice (once with an absolute RootPath, once with a relative RootPath resolved via TaskEnvironment) and asserts identical output, validating that the TaskEnvironment.GetAbsolutePath() integration preserves behavior.
  • TestRelativeFallbackSearchPathProducesSameResultAsAbsolute — same pattern for TargetFrameworkFallbackSearchPaths: verifies a relative fallback path resolved via TaskEnvironment produces the same result as the equivalent absolute path.

@OvesN OvesN self-assigned this Apr 7, 2026
Copilot AI review requested due to automatic review settings April 7, 2026 08:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the built-in GetReferenceAssemblyPaths task to the TaskEnvironment API to support correct path resolution under multithreaded MSBuild execution, and updates internal caching to be thread-safe.

Changes:

  • Mark GetReferenceAssemblyPaths as multithreadable and route relative path resolution through TaskEnvironment.GetAbsolutePath.
  • Replace a non-thread-safe static cache (bool?) with a thread-safe Lazy<bool> for the .NET 3.5 SP1 sentinel GAC lookup.
  • Add unit tests validating relative vs absolute behavior for RootPath and TargetFrameworkFallbackSearchPaths.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/Tasks/GetReferenceAssemblyPaths.cs Adds TaskEnvironment integration, multithreadable task surface, and thread-safe sentinel caching.
src/Tasks.UnitTests/GetReferencePaths_Tests.cs Adds regressions to ensure relative inputs resolved via TaskEnvironment match absolute-input behavior.

Comment thread src/Tasks/GetReferenceAssemblyPaths.cs
Comment thread src/Tasks.UnitTests/GetReferencePaths_Tests.cs Outdated
Comment thread src/Tasks.UnitTests/GetReferencePaths_Tests.cs Outdated
OvesN and others added 2 commits April 8, 2026 08:40
@OvesN OvesN requested review from JanProvaznik and SimaTian April 8, 2026 07:20
OvesN and others added 2 commits April 8, 2026 13:29
…enceAssemblyPaths-task-to-Task-Environment-API
…enceAssemblyPaths-task-to-Task-Environment-API
@JanProvaznik
Copy link
Copy Markdown
Member

/review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 10, 2026

Expert Code Review (command) completed successfully!

…enceAssemblyPaths-task-to-Task-Environment-API
@OvesN OvesN enabled auto-merge (squash) April 14, 2026 09:05
Comment thread src/Tasks.UnitTests/GetReferencePaths_Tests.cs Outdated
@OvesN OvesN disabled auto-merge April 14, 2026 09:35
@OvesN OvesN merged commit 5e982ce into dotnet:main Apr 14, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate GetReferenceAssemblyPaths to TaskEnvironment API

4 participants