[Fix] MSBuild Producing Different Output Paths if the Paths are Passes as Absolute or Relative
Fixes #13672
Context
On Unix, Directory.GetCurrentDirectory() resolves symlinks. As a result, invoking MSBuild from a symlinked working directory with a relative project path could produce canonical /real/... project/output paths, while passing the same project through an absolute symlink path preserved /link/.... This made properties such as MSBuildProjectDirectory and TargetDir inconsistent for the same project.
Changes Made
- Resolve relative project paths against the logical shell working directory from
PWDwhen it matches the physical current directory. - Keep Windows behavior unchanged.
- Avoid rebasing relative paths that contain
.., since parent traversal through a symlink can refer to a different physical location. - Use the same logical project path handling when locating project-directory response files.
- Added Unix-only regression coverage for symlinked working directories and response-file discovery.
Testing
- Built
Microsoft.Build.CommandLine.UnitTests.csprojsuccessfully. - Ran existing Windows response-file regression test successfully.
- Verified new Unix-only tests compile and are skipped on Windows.
- Ran
git diff --checksuccessfully.
/review
❌ Expert Code Review (command) failed. Please review the logs for details.
/review
⚠️ Security scanning failed for Expert Code Review (command). Review the logs for details.
Expert review of PR #13752 completed. The subagent posted inline review comments and a final review verdict directly on the PR. Key findings: wrong test attribute (UnixOnlyFact vs RequiresSymbolicLinksFact), LINQ allocation in hot path (Split().Contains("..")), missing edge-case tests, libc_free P/Invoke can use Marshal.FreeHGlobal, no diagnostic logging when rebase fires, and redundant Path.GetFullPath in CommandLineParser.cs.
/review
⚠️ Security scanning failed for Expert Code Review (command). Review the logs for details.
Expert-reviewer subagent completed and posted its review findings directly to PR #13752. The review identified 2 moderate issues (switchesFullyGathered ordering in XMake.cs, missing platform annotations on RealPath) and 3 nits (test attribute convention, null check style, string cleanup style). The core design was validated as correct.