Enlighten RAR task#13319
Conversation
There was a problem hiding this comment.
Pull request overview
This PR advances “RAR task enlightening” by routing path resolution and environment access through TaskEnvironment (including in the out-of-proc RAR node), and by upgrading several RAR inputs from strings to AbsolutePath to ensure stable, project-relative-to-absolute resolution in multithreaded builds.
Changes:
- RAR and related resolvers now use
TaskEnvironmentfor absolute path conversion and environment variable access. - Out-of-proc RAR node now hydrates a multithreaded
TaskEnvironmentusing the client project directory. - Introduces a new ChangeWave (18.6) and updates task/unit test code to provide
TaskEnvironment.
Reviewed changes
Copilot reviewed 51 out of 51 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Tasks/SystemState.cs | Uses TaskEnvironment for state file path handling during precomputed cache load. |
| src/Tasks/StateFileBase.cs | Clarifies expectation that state file path is absolute. |
| src/Tasks/RedistList.cs | Moves redist list paths to AbsolutePath and enables TaskEnvironment-based absolutization. |
| src/Tasks/InstalledSDKResolver.cs | Caches absolute SDK root paths for resolver probing. |
| src/Tasks/GetReferenceAssemblyPaths.cs | Marks task as multi-threadable and passes TaskEnvironment into GAC resolution. |
| src/Tasks/AssemblyDependency/Resolver.cs | Adds TaskEnvironment to resolver base for consistent path/env usage. |
| src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs | Converts several inputs to AbsolutePath, adds MT task interface, and updates RAR execution to pass TaskEnvironment through the pipeline. |
| src/Tasks/AssemblyDependency/ReferenceTable.cs | Propagates TaskEnvironment into resolution pipeline and normalizes resolved paths. |
| src/Tasks/AssemblyDependency/Reference.cs | Adds IsFrameworkFile overload for AbsolutePath[] framework paths. |
| src/Tasks/AssemblyDependency/RawFilenameResolver.cs | Resolves raw filename candidate via TaskEnvironment. |
| src/Tasks/AssemblyDependency/Node/RarNodeExecuteRequest.cs | Captures project directory for out-of-proc node TaskEnvironment creation. |
| src/Tasks/AssemblyDependency/Node/OutOfProcRarNodeEndpoint.cs | Creates a multithreaded TaskEnvironment per request using the client project directory. |
| src/Tasks/AssemblyDependency/HintPathResolver.cs | Resolves hint path using TaskEnvironment and canonicalizes. |
| src/Tasks/AssemblyDependency/GlobalAssemblyCache.cs | Switches env-var access to TaskEnvironment and threads it through GetLocation APIs. |
| src/Tasks/AssemblyDependency/GacResolver.cs | Threads TaskEnvironment into GAC resolver construction. |
| src/Tasks/AssemblyDependency/FrameworkPathResolver.cs | Threads TaskEnvironment into framework path resolver construction. |
| src/Tasks/AssemblyDependency/DirectoryResolver.cs | Caches absolute search path via TaskEnvironment. |
| src/Tasks/AssemblyDependency/CandidateAssemblyFilesResolver.cs | Threads TaskEnvironment into candidate assembly files resolver construction. |
| src/Tasks/AssemblyDependency/AssemblyResolution.cs | Threads TaskEnvironment through resolver compilation APIs. |
| src/Tasks/AssemblyDependency/AssemblyFoldersResolver.cs | Threads TaskEnvironment into AssemblyFolders resolver. |
| src/Tasks/AssemblyDependency/AssemblyFoldersFromConfig/AssemblyFoldersFromConfigResolver.cs | Uses TaskEnvironment for cache escape-hatch env var access and passes it into cache. |
| src/Tasks/AssemblyDependency/AssemblyFoldersFromConfig/AssemblyFoldersFromConfigCache.cs | Uses TaskEnvironment for cache escape-hatch env var access. |
| src/Tasks/AssemblyDependency/AssemblyFoldersExResolver.cs | Uses TaskEnvironment for cache escape-hatch env var access and passes it into cache. |
| src/Tasks.UnitTests/RARPrecomputedCache_Tests.cs | Updates RAR tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/HintPathResolver_Tests.cs | Updates resolver test to provide TaskEnvironment. |
| src/Tasks.UnitTests/GetReferencePaths_Tests.cs | Updates task test to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/WinMDTests.cs | Updates RAR tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/VerifyTargetFrameworkHigherThanRedist.cs | Updates RAR tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/VerifyTargetFrameworkAttribute.cs | Updates RAR tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/VerifyIgnoreVersionForFrameworkReference.cs | Updates RAR tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/SuggestedRedirects.cs | Updates RAR tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/StronglyNamedDependencyAutoUnify.cs | Updates RAR tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/StronglyNamedDependencyAppConfig.cs | Updates RAR tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/StronglyNamedDependency.cs | Updates RAR tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/SpecificVersionPrimary.cs | Updates RAR tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/ResolveAssemblyReferenceTestFixture.cs | Updates helper to pass TaskEnvironment into GAC resolution. |
| src/Tasks.UnitTests/AssemblyDependency/Perf.cs | Updates perf tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/NonSpecificVersionStrictPrimary.cs | Updates RAR tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/Node/RarNodeExecuteRequest_Tests.cs | Updates node request tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/Node/OutOfProcRarNode_Tests.cs | Updates node tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/Miscellaneous.cs | Updates RAR tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/InstalledSDKResolverFixture.cs | Updates resolver fixture to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/GlobalAssemblyCacheTests.cs | Updates cache tests to pass TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/FilePrimary.cs | Updates RAR tests to provide TaskEnvironment. |
| src/Tasks.UnitTests/AssemblyDependency/AssemblyFoldersFromConfig_Tests.cs | Updates tests to provide TaskEnvironment. |
| src/Framework/MultiThreadedTaskEnvironmentDriver.cs | Moves driver into Framework layer and updates env-var comparer dependency. |
| src/Framework/MultiProcessTaskEnvironmentDriver.cs | Moves driver into Framework layer and routes env-var ops through Framework utilities. |
| src/Framework/FrameworkCommunicationsUtilities.cs | Adds Framework-local env-var utilities needed by moved drivers. |
| src/Framework/ChangeWaves.cs | Adds new wave 18.6 and includes it in AllWaves. |
| src/Build/Microsoft.Build.csproj | Removes compilation of drivers from Build project (now in Framework). |
| src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs | Updates comment to reflect new Framework env-var utilities usage. |
Comments suppressed due to low confidence (1)
src/Tasks/AssemblyDependency/ReferenceTable.cs:496
- When
assemblyFileNameis relative,reference.FullPathis made absolute viaTaskEnvironment, but the subsequent_fileExists,_directoryExists,_getAssemblyName, andResolvedSearchPathlogic still uses the original (potentially relative)assemblyFileName. In multithreaded/out-of-proc scenarios this can probe the wrong directory and fail to resolve assemblies. Use the resolved absolute path (e.g.,reference.FullPath) consistently for file system checks and assembly name probing.
…on as it is expensive and would be done in ReferenceTable centrally.
|
/review |
JanProvaznik
left a comment
There was a problem hiding this comment.
review point 1 before I get to the juicy stuff:
pls remove everywhere t.TaskEnvironment = TaskEnvironmentHelper.CreateForTest(); which will make the PR also optically smaller
…est() from tests and change Wave18_6 to Wave18_8 Remove property-assignment-style TaskEnvironmentHelper.CreateForTest() additions from test files where they were not required by production API changes. Keep method argument additions where production code signatures require them. Change ChangeWave from 18_6 to 18_8 and add Wave18_8 definition. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
JanProvaznik
left a comment
There was a problem hiding this comment.
a few things to improve but seems solid on the high level
…rror message indicating that these modes cannot be used together.
|
For the OOP + MT issues, I will remember this feedback and investigate those, but for now we will move fixing the OOP + MT fully to another PR. In this PR I will only make the current OOP code work through task environment, as I can not separate those changes.
fixed, thank you!
The StateFile and AppConfigFile are getting resolved through task environment which we start sending through the boundary, so it does not matter anymore whether they are relative or not, thus I removed the absolutization. |
JanProvaznik
left a comment
There was a problem hiding this comment.
1 race condition candidate and 1 usage of clear API
otherwise more feedback is low severity and I am OK with merging it
Unit test coverage for -mt path is not great, have you at least run it on artificial solutions with high parallelism?
|
Running the exp insertion to check the latest changes and should be merging as soon as possible after it. |
Fixes #12483
Context
RAR task enlightening. While auditing the inputs in build logs, only
StateFile,AppConfigFile, andCandidateAssemblyFileswere obviously unenlightened, but several other inputs (TargetFrameworkDirectories, per-referenceHintPath,AssemblyFoldersExregistry values,AssemblyFoldersFromConfigdirectory entries, …) are also not guaranteed to be absolute. They are now absolutized viaTaskEnvironment.GetAbsolutePath.Changes Made
TaskEnvironmentfor proper path resolution (instead of just updatingStateFileandAppConfigFile)TaskEnvironementobject and use them for path absolutization of the inputs that are not absolutized prior.AbsolutePathstructs instead of strings.Breaking changes under a ChangeWave:
AppConfigFileresulted before in failure while now it is skipped (as if it was null before)StateFile.ItemSpecis used for the path instead ofStateFile.ToString()which could be otherwise defined in a customITaskItemTesting (in progress)
Checklist: