Fix Unix paths normalization in properties in /mt mode.#13439
Merged
AR-May merged 4 commits intodotnet:mainfrom Mar 24, 2026
Merged
Fix Unix paths normalization in properties in /mt mode.#13439AR-May merged 4 commits intodotnet:mainfrom
AR-May merged 4 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Unix path normalization under /mt by ensuring the Unix-path heuristic doesn’t rely on the process-wide current working directory when no base directory is provided, avoiding unresolved backslashes in generated paths.
Changes:
- Update
FileUtilities.LooksLikeUnixFilePathto resolve directory-existence checks againstFileUtilities.CurrentThreadWorkingDirectorywhenbaseDirectoryis empty. - Prevent
/mtbuilds on Unix from incorrectly treating backslash-containing relative paths as non-path strings due to CWD mismatches.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
JanProvaznik
approved these changes
Mar 24, 2026
This was referenced Mar 24, 2026
dfederm
pushed a commit
to dfederm/msbuild
that referenced
this pull request
Apr 9, 2026
Fixes dotnet#13425 ### Context Blazor WASM builds (and other projects) fail under /mt mode on Unix with `DirectoryNotFoundException` because paths contain unresolved backslashes, e.g.: ``` obj\Debug/net8.0/Net8BlazorWasmApp.csproj.AssemblyReference.cache ``` The root cause is in `FileUtilities.LooksLikeUnixFilePath`. This method checks whether the value looks like a unix path by checking whether the first path segment (e.g., obj) actually exists as a directory. It is used in `FileUtilities.MaybeAdjustFilePath` which decides whether a string with backslashes should be normalized to forward slashes. However, `LooksLikeUnixFilePath`, when base directory is not passed to the method, relies on CWD for the directory existence check. This breaks in /mt mode. ### Changes Made Use `CurrentThreadWorkingDirectory` for resolving the absolute path to check for existence, when base path is not provided. ### Testing - Tested on local repro, this fixes the original issue. - Unit test. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Fixes #13425
Context
Blazor WASM builds (and other projects) fail under /mt mode on Unix with
DirectoryNotFoundExceptionbecause paths contain unresolved backslashes, e.g.:The root cause is in
FileUtilities.LooksLikeUnixFilePath. This method checks whether the value looks like a unix path by checking whether the first path segment (e.g., obj) actually exists as a directory. It is used inFileUtilities.MaybeAdjustFilePathwhich decides whether a string with backslashes should be normalized to forward slashes. However,LooksLikeUnixFilePath, when base directory is not passed to the method, relies on CWD for the directory existence check. This breaks in /mt mode.Changes Made
Use
CurrentThreadWorkingDirectoryfor resolving the absolute path to check for existence, when base path is not provided.Testing