Skip to content

Enlighten GetFrameworkPath and GetFrameworkSdkPath.#13282

Open
AR-May wants to merge 2 commits intodotnet:mainfrom
AR-May:enlighten-more-tasks-8
Open

Enlighten GetFrameworkPath and GetFrameworkSdkPath.#13282
AR-May wants to merge 2 commits intodotnet:mainfrom
AR-May:enlighten-more-tasks-8

Conversation

@AR-May
Copy link
Member

@AR-May AR-May commented Feb 23, 2026

Context

Enlighten GetFrameworkPath and GetFrameworkSdkPath tasks.

Changes Made

  • GetFrameworkPath and GetFrameworkSdkPath depend on the ToolLocationHelper and FrameworkLocationHelper that uses environment variables to compute the locations of tools and frameworks. They then store it in process-wide cache. GetFrameworkPath should be safe as used environment variables are not supposed to be modified during the build by engine or tasks. To be on the safe side, merge after Prevent tasks from modifying immutable environment variables in MT mode #13273 that ensures that those variables does not change.
  • added locks to GetFrameworkSdkPath to make it thread-safe.

Testing

Unit tests

Notes

merge after #13273

We also assume that environment variables that supposed to contain path to objects, like "COMPLUS_INSTALLROOT" is absolute.
This was an implicit assumption prior this change as well.

Copilot AI review requested due to automatic review settings February 23, 2026 09:50
Copy link
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 “enlightens” the GetFrameworkPath and GetFrameworkSdkPath MSBuild tasks so they can run in-process under multi-threaded builds by marking them as multi-threadable, and it hardens GetFrameworkSdkPath’s static caching against concurrent access.

Changes:

  • Mark GetFrameworkPath and GetFrameworkSdkPath with [MSBuildMultiThreadableTask] so TaskRouter can run them in-proc in MT mode.
  • Make GetFrameworkSdkPath’s process-wide cached SDK paths thread-safe via a shared lock and double-checked initialization.

Reviewed changes

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

File Description
src/Tasks/GetFrameworkSDKPath.cs Adds MT-task attribute and protects static SDK path caches with locking.
src/Tasks/GetFrameworkPath.cs Adds MT-task attribute to allow in-proc execution in multi-threaded mode.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@AR-May AR-May self-assigned this Feb 23, 2026
Copy link
Member

@JanProvaznik JanProvaznik left a comment

Choose a reason for hiding this comment

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

apart from the comment looks good

else
{
path = FrameworkFileUtilities.EnsureTrailingSlash(path);
Log.LogMessageFromResources(MessageImportance.Low, "GetFrameworkSdkPath.FoundSDK", path);
Copy link
Member

Choose a reason for hiding this comment

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

note that there is a logging race condition - only one task would do this logging that it found/didnt' find sdk

I'd recommend moving the logging after the lock

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.

3 participants