Skip to content

Enlighten RAR task#13319

Merged
AR-May merged 46 commits into
dotnet:mainfrom
AR-May:enlighten-RAR-2
May 19, 2026
Merged

Enlighten RAR task#13319
AR-May merged 46 commits into
dotnet:mainfrom
AR-May:enlighten-RAR-2

Conversation

@AR-May
Copy link
Copy Markdown
Member

@AR-May AR-May commented Mar 3, 2026

Fixes #12483

Context

RAR task enlightening. While auditing the inputs in build logs, only StateFile, AppConfigFile, and CandidateAssemblyFiles were obviously unenlightened, but several other inputs (TargetFrameworkDirectories, per-reference HintPath, AssemblyFoldersEx registry values, AssemblyFoldersFromConfig directory entries, …) are also not guaranteed to be absolute. They are now absolutized via TaskEnvironment.GetAbsolutePath.

Changes Made

  • RAR out-of-proc node now uses the multithreaded TaskEnvironment for proper path resolution (instead of just updating StateFile and AppConfigFile)
  • Resolvers now take TaskEnvironement object and use them for path absolutization of the inputs that are not absolutized prior.
  • Some of the inputs now are backed up with AbsolutePath structs instead of strings.

Breaking changes under a ChangeWave:

  • Empty AppConfigFile resulted before in failure while now it is skipped (as if it was null before)
  • StateFile.ItemSpec is used for the path instead of StateFile.ToString() which could be otherwise defined in a custom ITaskItem

Testing (in progress)

Checklist:

  • Manual tests (building OC in mt mode)
  • Unit tests
  • Exp insertion
  • Test RAR node mode (building OC with RAR out-of-proc node)
  • VMR
  • Analyzer

@AR-May AR-May self-assigned this Mar 4, 2026
Comment thread src/Framework/FrameworkCommunicationsUtilities.cs Outdated
@AR-May AR-May marked this pull request as ready for review March 4, 2026 13:48
Copilot AI review requested due to automatic review settings March 4, 2026 13:48
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 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 TaskEnvironment for absolute path conversion and environment variable access.
  • Out-of-proc RAR node now hydrates a multithreaded TaskEnvironment using 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 assemblyFileName is relative, reference.FullPath is made absolute via TaskEnvironment, but the subsequent _fileExists, _directoryExists, _getAssemblyName, and ResolvedSearchPath logic 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.

Comment thread src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs Outdated
Comment thread src/Tasks/SystemState.cs Outdated
Comment thread src/Tasks/AssemblyDependency/RawFilenameResolver.cs Outdated
Comment thread src/Tasks/InstalledSDKResolver.cs Outdated
Comment thread src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs
Comment thread src/Tasks/AssemblyDependency/ReferenceTable.cs Outdated
Comment thread src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs Outdated
Comment thread src/Build/Microsoft.Build.csproj Outdated
Comment thread src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs Outdated
Comment thread src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs Outdated
Comment thread src/Tasks/StateFileBase.cs
Comment thread src/Tasks/AssemblyDependency/AssemblyFoldersResolver.cs Outdated
Comment thread src/Tasks/AssemblyDependency/ReferenceTable.cs Outdated
Comment thread src/Tasks.UnitTests/AssemblyDependency/AssemblyFoldersFromConfig_Tests.cs Outdated
@AR-May
Copy link
Copy Markdown
Member Author

AR-May commented Mar 13, 2026

I separated moving drivers to the Framework project to another PR: #13380.
Merge this changes after #13380 is merged. There would be build errors meanwhile.

Comment thread src/Tasks.UnitTests/AssemblyDependency/GlobalAssemblyCacheTests.cs Outdated
Comment thread src/Tasks/AssemblyDependency/Node/OutOfProcRarNodeEndpoint.cs
@AR-May
Copy link
Copy Markdown
Member Author

AR-May commented Apr 16, 2026

/review

Copy link
Copy Markdown
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.

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

Comment thread src/Tasks/AssemblyDependency/ReferenceTable.cs Outdated
Comment thread src/Tasks.UnitTests/AssemblyDependency/Node/OutOfProcRarNode_Tests.cs Outdated
Comment thread src/Tasks.UnitTests/AssemblyDependency/Node/RarNodeExecuteRequest_Tests.cs Outdated
Comment thread src/Tasks.UnitTests/AssemblyDependency/Miscellaneous.cs Outdated
JanProvaznik and others added 4 commits May 4, 2026 11:41
…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>
Copy link
Copy Markdown
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.

a few things to improve but seems solid on the high level

Comment thread src/Tasks/GetReferenceAssemblyPaths.cs Outdated
Comment thread src/Framework/ChangeWaves.cs
Comment thread src/Tasks.UnitTests/AssemblyDependency/VerifyTargetFrameworkAttribute.cs Outdated
Comment thread src/Tasks/AssemblyDependency/Node/OutOfProcRarClient.cs Outdated
Comment thread src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs Outdated
Comment thread src/Tasks/SystemState.cs Outdated
Comment thread src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs Outdated
Comment thread src/Tasks/TaskEnvironmentExtensions.cs Outdated
Comment thread src/Tasks/Resources/Strings.resx Outdated
@AR-May
Copy link
Copy Markdown
Member Author

AR-May commented May 11, 2026

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.

NEW1_StringsInitialize_HasPublicationRace

fixed, thank you!

NEW4 StateFile / AppConfigFile no longer absolutized at the wire boundary

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.

Comment thread documentation/wiki/ChangeWaves.md Outdated
Comment thread src/Tasks/AssemblyDependency/Node/OutOfProcRarNodeEndpoint.cs Outdated
Comment thread src/Tasks.UnitTests/RawFilenameResolver_Tests.cs Outdated
Copy link
Copy Markdown
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.

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?

Comment thread src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs Outdated
Comment thread src/Tasks/SystemState.cs Outdated
@AR-May
Copy link
Copy Markdown
Member Author

AR-May commented May 18, 2026

Running the exp insertion to check the latest changes and should be merging as soon as possible after it.

@AR-May AR-May merged commit d9c38b1 into dotnet:main May 19, 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 RAR task to the new task API

5 participants