Skip to content

Enlighten FindUnderPath and AssignTargetPath tasks#13069

Merged
AR-May merged 13 commits intodotnet:mainfrom
AR-May:enlighten-tasks-2
Feb 19, 2026
Merged

Enlighten FindUnderPath and AssignTargetPath tasks#13069
AR-May merged 13 commits intodotnet:mainfrom
AR-May:enlighten-tasks-2

Conversation

@AR-May
Copy link
Copy Markdown
Member

@AR-May AR-May commented Jan 20, 2026

Related to #13025

@AR-May AR-May force-pushed the enlighten-tasks-2 branch from 69fb9af to 22d83b3 Compare January 21, 2026 14:58
@AR-May AR-May self-assigned this Jan 28, 2026
@AR-May AR-May marked this pull request as ready for review February 9, 2026 11:59
Copilot AI review requested due to automatic review settings February 9, 2026 11:59
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 FindUnderPath and AssignTargetPath tasks to MSBuild’s multi-threadable task API by introducing TaskEnvironment-based path resolution, aligning with the ongoing effort in #13025 to transfer remaining tasks to the new API.

Changes:

  • Mark FindUnderPath and AssignTargetPath as [MSBuildMultiThreadableTask] and implement IMultiThreadableTask with a TaskEnvironment property.
  • Replace Path.GetFullPath / Directory.GetCurrentDirectory usage with TaskEnvironment.GetAbsolutePath(...) and TaskEnvironment.ProjectDirectory.
  • Update unit tests to initialize TaskEnvironment via TaskEnvironmentHelper.CreateForTest().

Reviewed changes

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

File Description
src/Tasks/ListOperators/FindUnderPath.cs Migrates full-path resolution to TaskEnvironment for multithreaded execution.
src/Tasks/AssignTargetPath.cs Uses TaskEnvironment for absolute paths and replaces current-directory logic with ProjectDirectory.
src/Tasks.UnitTests/FindUnderPath_Tests.cs Sets TaskEnvironment in tests to support IMultiThreadableTask execution.
src/Tasks.UnitTests/AssignTargetPath_Tests.cs Sets TaskEnvironment in tests to support IMultiThreadableTask execution.
Comments suppressed due to low confidence (1)

src/Tasks/AssignTargetPath.cs:117

  • Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
                            if (itemSpecFullFileNamePath.Value.StartsWith(fullRootPath.Value, StringComparison.OrdinalIgnoreCase))
                            {
                                // The item spec file is in the "cone" of the RootFolder. Return the relative path from the cone root.
                                targetPath = itemSpecFullFileNamePath.Value.Substring(fullRootPath.Value.Length);
                            }
                            else
                            {
                                // The item spec file is not in the "cone" of the RootFolder. Return the filename only.
                                targetPath = Path.GetFileName(Files[i].ItemSpec);
                            }

@AR-May
Copy link
Copy Markdown
Member Author

AR-May commented Feb 12, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@AR-May AR-May requested a review from JanProvaznik February 17, 2026 08:40
@AR-May AR-May merged commit 40eb7ab into dotnet:main Feb 19, 2026
10 checks passed
JanProvaznik added a commit to JanProvaznik/msbuild that referenced this pull request Feb 25, 2026
Enlighten FindUnderPath and AssignTargetPath tasks. Related to dotnet#13025

---------

Co-authored-by: Jan Provazník <janprovaznik@microsoft.com>
tommcdon added a commit that referenced this pull request Mar 16, 2026
…parators (#13369)

Investigation from VS feedback item
https://developercommunity.visualstudio.com/t/MSIX-Deployed-App-Fails-to-Find-Resource/11049946
led to finding of this issue

### Context

`AssignTargetPath` task in VS 18 Preview build to new code path gated
behind `ChangeWaves.Wave18_5` that uses
`AbsolutePath.GetCanonicalForm()` instead of the previous
`Path.GetFullPath()` for path normalization. `GetCanonicalForm()`
doesn't normalize consecutive directory separators (`\\` → `\`), unlike
`Path.GetFullPath()` which did. This resulted in a "flattening" of the
TargetPath, breaking the a Visual Studio deployment scenario.

Regression was introduced on
#13069.

### Changes Made


[AbsolutePath.GetCanonicalForm()](https://github.com/dotnet/msbuild/blob/7d73e8e9074fe9a4420e38cd22d45645b28a11f7/src/Framework/PathHelpers/AbsolutePath.cs#L142)
has a fast-path optimization that skips calling
[Path.GetFullPath()](https://github.com/dotnet/msbuild/blob/7d73e8e9074fe9a4420e38cd22d45645b28a11f7/src/Framework/PathHelpers/AbsolutePath.cs#L172)
when the path has no relative segments (/. or \.) and no mixed
separators (/ on Windows). However, it didn't check for consecutive
directory separators (e.g., \\), so paths like ...win-x64\\ were
returned unchanged. The fix adds a check for consecutive separators (\\
on Windows, // on Unix) so they fall through to
[Path.GetFullPath()](https://github.com/dotnet/msbuild/blob/7d73e8e9074fe9a4420e38cd22d45645b28a11f7/src/Framework/PathHelpers/AbsolutePath.cs#L172)
which normalizes them to a single separator.

### Testing

Added the appropriate unit tests. Also validated the originally reported
issue in the VS feedback ticket by patching binaries in VS.
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