Skip to content

Add GetCanonicalForm to the AbsolutePath API#13088

Merged
AR-May merged 9 commits into
dotnet:mainfrom
AR-May:update-absolute-path-api
Feb 9, 2026
Merged

Add GetCanonicalForm to the AbsolutePath API#13088
AR-May merged 9 commits into
dotnet:mainfrom
AR-May:update-absolute-path-api

Conversation

@AR-May
Copy link
Copy Markdown
Member

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

Context

It is quite often that Path.GetFullPath is used in the tasks code. For enlightening we would want to replace it with our own API. The candidate was TaskEnvironment.GetAbsolutePath for replacing.

However, they do not do the same set of actions. TaskEnvironment.GetAbsolutePath only absolutizes the path but does not resolve possible "." and ".." in the path or normalize path separators on Windows.
For some scenarios this is critical, for some that does not matter. We should provide an option for fully copy Path.GetFullPath behavior

Changes Made

  • Added AbsolutePath.GetCanonicalForm()

Testing

Added unit tests

@AR-May AR-May marked this pull request as ready for review January 22, 2026 13:52
Copilot AI review requested due to automatic review settings January 22, 2026 13:52
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 adds a GetFullPath() method to the AbsolutePath struct to provide an API that fully replicates Path.GetFullPath behavior, including resolving relative path segments ("." and "..") and normalizing directory separators on Windows. This enables replacing direct Path.GetFullPath calls in task code with a more controlled API.

Changes:

  • Added GetFullPath() method with optimization to avoid allocations when no normalization is needed
  • Added comprehensive unit tests for both Windows and Unix platforms

Reviewed changes

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

File Description
src/Framework/PathHelpers/AbsolutePath.cs Implements GetFullPath() with detection logic for relative segments and separator normalization needs
src/Framework.UnitTests/AbsolutePath_Tests.cs Adds test cases for null paths, Windows path normalization, and Unix path normalization

Comment thread src/Framework.UnitTests/AbsolutePath_Tests.cs
Comment thread src/Framework/PathHelpers/AbsolutePath.cs Outdated
Comment thread src/Framework/PathHelpers/AbsolutePath.cs
Comment thread src/Framework/PathHelpers/AbsolutePath.cs Outdated
@AR-May AR-May force-pushed the update-absolute-path-api branch from f1d94ca to d9b4d89 Compare January 28, 2026 12:26
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.

should this pr also use this new method on the already migrated tasks where needed?

Comment thread src/Framework/PathHelpers/AbsolutePath.cs Outdated
Comment thread src/Framework/PathHelpers/AbsolutePath.cs Outdated
Comment thread src/Framework/PathHelpers/AbsolutePath.cs
@AR-May AR-May changed the title Add GetFullPath to the AbsolutePath API Add GetCanonicalForm to the AbsolutePath API Jan 28, 2026
@AR-May AR-May self-assigned this Jan 28, 2026
@AR-May
Copy link
Copy Markdown
Member Author

AR-May commented Jan 28, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@AR-May
Copy link
Copy Markdown
Member Author

AR-May commented Jan 29, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@AR-May
Copy link
Copy Markdown
Member Author

AR-May commented Jan 30, 2026

should this pr also use this new method on the already migrated tasks where needed?

let me do it in separate pr for that, i would like to get this in and start using in my draft prs.

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

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

Comment thread src/Framework/PathHelpers/AbsolutePath.cs
Comment thread src/Framework/PathHelpers/AbsolutePath.cs
Comment thread src/Framework.UnitTests/AbsolutePath_Tests.cs
Comment thread src/Framework/PathHelpers/AbsolutePath.cs
Comment thread src/Framework/PathHelpers/AbsolutePath.cs
This was referenced May 17, 2026
github-actions Bot pushed a commit to IntelliTect/Multitool that referenced this pull request May 19, 2026
Updated [Microsoft.Build](https://github.com/dotnet/msbuild) from 18.4.0
to 18.6.3.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.Build's
releases](https://github.com/dotnet/msbuild/releases)._

## 18.6.3

## What's Changed
* Improve cross-platform node discovery for reuse with NodeMode
filtering by @​Copilot in dotnet/msbuild#13256
* Updated common types XSD to remove errors from redefining `Include`
attributes by @​glektarssza in
dotnet/msbuild#13284
* Update VersionPrefix to 18.6.0 + insertion flow by @​MichalPavlik in
dotnet/msbuild#13296
* Log warnings for skipped STR resource keys instead of failing the
build by @​OvesN in dotnet/msbuild#13291
* Isolate MSBuildTaskHost from the rest of MSBuild Codebase by
@​DustinCampbell in dotnet/msbuild#13232
* Improve error messages when ToolTask overrides exit code 0 to -1 due
to logged errors by @​OvesN in
dotnet/msbuild#13303
* Migrate Exec task to TaskEnvironment API by @​Copilot in
dotnet/msbuild#13171
* Enhance crash telemetry with richer diagnostics and EndBuild hang
detection by @​YuliiaKovalova in
dotnet/msbuild#13304
* [main] Update dependencies from nuget/nuget.client by
@​dotnet-maestro[bot] in dotnet/msbuild#13309
* [IBuildEngine callbacks] Stage 2: RequestCores/ReleaseCores by
@​JanProvaznik in dotnet/msbuild#13306
* Only get command line args names on modern .NET by @​baronfel in
dotnet/msbuild#13314
* Detect and correct worker node over-provisioning by @​Copilot in
dotnet/msbuild#13220
* Add App Host Support for MSBuild by @​YuliiaKovalova in
dotnet/msbuild#13175
* [main] Update dependencies from dotnet/arcade by @​dotnet-maestro[bot]
in dotnet/msbuild#13311
* Fix ObjectDisposedException in BuildsWhileBuildIsRunningOnServer test
by @​Copilot in dotnet/msbuild#13316
* Add PoC of pipelines check skill by @​JanKrivanek in
dotnet/msbuild#13242
* Fix CodeSign.MissingSigningCert for xsd/Update-MSBuildXsds.ps1 by
@​JanProvaznik in dotnet/msbuild#13320
* Fix task host launch regressions from apphost support by
@​YuliiaKovalova in dotnet/msbuild#13325
* Enlighten GetFrameworkPath and GetFrameworkSdkPath. by @​AR-May in
dotnet/msbuild#13282
* Add VMR codeflow health check to pipelines skill by @​JanProvaznik in
dotnet/msbuild#13326
* [main] Update dependencies from dotnet/roslyn by @​dotnet-maestro[bot]
in dotnet/msbuild#13281
* Fix GenerateResource to track all ResXFileRef linked files for
incremental builds by @​OvesN in
dotnet/msbuild#13327
* Add escape hatch for not sharing assemblies from tools directory by
@​AR-May in dotnet/msbuild#13305
* Add merge-dependency-updates skill for bot PR triage by @​JanProvaznik
in dotnet/msbuild#13331
* Add diagnostic data to crash/hang telemetry and move null-Project
check after RetrieveFromCache by @​YuliiaKovalova in
dotnet/msbuild#13332
* Update remote-host-object.md with SDK .tlb shipping and IDispatch
example by @​YuliiaKovalova in
dotnet/msbuild#13324
* [main] Update dependencies from dotnet/arcade by @​dotnet-maestro[bot]
in dotnet/msbuild#13341
* improve task migration skill by @​JanProvaznik in
dotnet/msbuild#13234
* Fix telemetry PII concerns: sanitize exceptions, project paths, and
custom names by @​YuliiaKovalova in
dotnet/msbuild#13344
* Use .exe.config when loading "as full Framework" by @​rainersigwald in
dotnet/msbuild#13349
* Fix RequestCores/ReleaseCores fallback in OOP TaskHost: throw
NotImplementedException instead of logging error by @​JanProvaznik in
dotnet/msbuild#13345
* Fixed indentation for
_GetCopyToOutputDirectoryItemsFromTransitiveProjectReferences by
@​CEbbinghaus in dotnet/msbuild#13358
* Fix Unix SessionId in handshake to enable cross-terminal node reuse by
@​JakeRadMSFT in dotnet/msbuild#13354
* Revert "Migrate Exec task to TaskEnvironment API" by @​JanProvaznik in
dotnet/msbuild#13367
* Look for apphost when considering node reuse by @​rainersigwald in
dotnet/msbuild#13368
* Move lots of shared code to Microsoft.Build.Framework by
@​DustinCampbell in dotnet/msbuild#13364
* [main] Source code updates from dotnet/dotnet by @​dotnet-maestro[bot]
in dotnet/msbuild#13353
* Fix ScheduleTimeRecord.AccumulatedTime hang during solution close by
@​YuliiaKovalova in dotnet/msbuild#13375
* Update runtime package references to 10.0.3 by @​Copilot in
dotnet/msbuild#13376
* [main] Source code updates from dotnet/dotnet by @​dotnet-maestro[bot]
in dotnet/msbuild#13378
* Fix ProjectImports.zip regression from shared FileUtilities statics by
@​JanProvaznik in dotnet/msbuild#13382
* Enrich EndBuild hang diagnostics with logging service and submission
state by @​YuliiaKovalova in
dotnet/msbuild#13385
* Enhance path normalization: add handling for consecutive directory
separators by @​tommcdon in dotnet/msbuild#13369
* Move task environment drivers to Framework. by @​AR-May in
dotnet/msbuild#13380
* Update MicrosoftBuildVersion in analyzer template by
@​github-actions[bot] in dotnet/msbuild#13298
* Replace ProjectCacheService null Project crash with diagnostic
telemetry by @​YuliiaKovalova in
dotnet/msbuild#13396
* Add agentic workflow to auto-close PRs older than 180 days by
@​Copilot in dotnet/msbuild#13400
* Localized file check-in by OneLocBuild Task: Build definition ID 9434:
Build ID 13575337 by @​dotnet-bot in
dotnet/msbuild#13394
* Respect MSBUILDPRESERVETOOLTEMPFILES in ProcessExit cleanup by
@​DmitriyShepelev in dotnet/msbuild#13395
 ... (truncated)

## 18.5.4

## What's Changed
* remove dead code by @​SimaTian in
dotnet/msbuild#13125
* Update VersionPrefix to 18.5.0 + insertion flow by @​YuliiaKovalova in
dotnet/msbuild#13134
* add multithreaded task migration agent skill by @​JanProvaznik in
dotnet/msbuild#13131
* Update MicrosoftBuildVersion in analyzer template by
@​github-actions[bot] in dotnet/msbuild#13139
* Migrate VerifyFileHash task to TaskEnvironment API by @​Copilot in
dotnet/msbuild#13112
* Migrate GetFileHash tasks to TaskEnvironment API by @​Copilot in
dotnet/msbuild#13111
* Diagram of VS/SDK component interactions by @​rainersigwald in
dotnet/msbuild#13127
* Fix package validation telemetry assembly resolution warnings by
@​JanProvaznik in dotnet/msbuild#13144
* Adds validation to throw MSB4259 when property references contain
leading or trailing whitespace outside of conditions. by
@​huulinhnguyen-dev in dotnet/msbuild#13076
* Localized file check-in by OneLocBuild Task: Build definition ID 9434:
Build ID 13203963 by @​dotnet-bot in
dotnet/msbuild#13151
* Add MSBuild app host design by @​YuliiaKovalova in
dotnet/msbuild#12857
* Add Stabilize-Release.ps1 script for release process by
@​rainersigwald in dotnet/msbuild#13146
* Fix chained item function empty result comparison in conditions by
@​JanProvaznik in dotnet/msbuild#12901
* [main] Update dependencies from dotnet/roslyn by @​dotnet-maestro[bot]
in dotnet/msbuild#13162
* [main] Update dependencies from dotnet/arcade by @​dotnet-maestro[bot]
in dotnet/msbuild#13160
* Localized file check-in by OneLocBuild Task: Build definition ID 9434:
Build ID 13217622 by @​dotnet-bot in
dotnet/msbuild#13163
* Fix items logged as type name during -getitem argument by @​Copilot in
dotnet/msbuild#13166
* Respect NetCoreSdkRoot property for TaskHostParameters by
@​ViktorHofer in dotnet/msbuild#13176
* Remove MachineIndependent configuration by @​Copilot in
dotnet/msbuild#13180
* Remove redundant #nullable disable from 153 files by @​Copilot in
dotnet/msbuild#13157
* Revert #​13076 "Adds validation to throw MSB4259 when property
references contain leading or trailing whitespace outside of conditions.
by @​JanProvaznik in dotnet/msbuild#13184
* Convert MSBuild.sln to slnx format and upate refs by @​ViktorHofer in
dotnet/msbuild#13185
* Implement IMultiThreadableTask for Move task by @​Copilot in
dotnet/msbuild#13108
* Add hostservices translation support for clr 4 task host by
@​YuliiaKovalova in dotnet/msbuild#13154
* Handle null ProjectFile in InvalidProjectFileException by
@​ViktorHofer in dotnet/msbuild#13179
* Add $(LatestDotNetCoreForMSBuild) infrastructure for centralized
framework targeting by @​Copilot in
dotnet/msbuild#13189
* Fix TaskHost crash when task returns string[] with null elements by
@​JanProvaznik in dotnet/msbuild#13190
* Revert "Refactor Microsoft.IO usage" by @​YuliiaKovalova in
dotnet/msbuild#13194
* Allow null SdkResult from SdkResolver.Resolve by @​rainersigwald in
dotnet/msbuild#13197
* Skill to test changes using just-built MSBuild by @​rainersigwald in
dotnet/msbuild#13202
* Tell Copilot not to allow breaking changes by @​rainersigwald in
dotnet/msbuild#13200
* Make nologo switch accept boolean values to enable explicit logo
display control by @​Copilot in
dotnet/msbuild#12541
* Migrate Unzip task to use TaskEnvironment API by @​Copilot in
dotnet/msbuild#13109
* Migrate ZipDirectory task to TaskEnvironment API by @​Copilot in
dotnet/msbuild#13110
* Localized file check-in by OneLocBuild Task: Build definition ID 9434:
Build ID 13246767 by @​dotnet-bot in
dotnet/msbuild#13204
* Add .NET Standard compatibility warnings by @​ViktorHofer in
dotnet/msbuild#13187
* Make WriteCodeFragment task locale-independent for reproducible builds
by @​Copilot in dotnet/msbuild#13192
* Localized file check-in by OneLocBuild Task: Build definition ID 9434:
Build ID 13249478 by @​dotnet-bot in
dotnet/msbuild#13207
* Fix TerminalLogger IndexOutOfRangeException when replaying binlog with
fewer nodes by @​Copilot in dotnet/msbuild#12809
* Migrate DownloadFile task to use TaskEnvironment API by @​Copilot in
dotnet/msbuild#13113
* Add CI job for 2-stage build with -mt mode by @​Copilot in
dotnet/msbuild#13124
* Localize AbsolutePath validation messages by @​JanProvaznik in
dotnet/msbuild#13115
* Refactor FrameworkFileUtilities for better performance by @​AR-May in
dotnet/msbuild#13143
* Add agent instructions for MSBuild repository by @​YuliiaKovalova in
dotnet/msbuild#13198
* Add GetCanonicalForm to the AbsolutePath API by @​AR-May in
dotnet/msbuild#13088
* Shouldly 4.3.0 by @​rainersigwald in
dotnet/msbuild#13213
* Migrate WriteCodeFragment task to use TaskEnvironment API by @​Copilot
in dotnet/msbuild#13169
* Run the issue-labeler over pull requests using polling by @​Copilot in
dotnet/msbuild#13223
* [main] Update dependencies from dotnet/arcade by @​dotnet-maestro[bot]
in dotnet/msbuild#13225
 ... (truncated)

Commits viewable in [compare
view](dotnet/msbuild@v18.4.0...v18.6.3).
</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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