Enlighten GetFrameworkPath and GetFrameworkSdkPath.#13282
Open
AR-May wants to merge 2 commits intodotnet:mainfrom
Open
Enlighten GetFrameworkPath and GetFrameworkSdkPath.#13282AR-May wants to merge 2 commits intodotnet:mainfrom
AR-May wants to merge 2 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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
GetFrameworkPathandGetFrameworkSdkPathwith[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>
Member
JanProvaznik
left a comment
There was a problem hiding this comment.
apart from the comment looks good
| else | ||
| { | ||
| path = FrameworkFileUtilities.EnsureTrailingSlash(path); | ||
| Log.LogMessageFromResources(MessageImportance.Low, "GetFrameworkSdkPath.FoundSDK", path); |
Member
There was a problem hiding this comment.
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
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.
Context
Enlighten
GetFrameworkPathandGetFrameworkSdkPathtasks.Changes Made
GetFrameworkPathandGetFrameworkSdkPathdepend on theToolLocationHelperandFrameworkLocationHelperthat 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.GetFrameworkSdkPathto 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.