msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

[Fix] MSBuild Producing Different Output Paths if the Paths are Passes as Absolute or Relative

Open AlesProkop opened this issue 6 months ago • 6 comments

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 PWD when 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.csproj successfully.
  • Ran existing Windows response-file regression test successfully.
  • Verified new Unix-only tests compile and are skipped on Windows.
  • Ran git diff --check successfully.

AlesProkop avatar May 13 '26 13:05 AlesProkop

/review

JanProvaznik avatar Jun 17 '26 13:06 JanProvaznik

❌ Expert Code Review (command) failed. Please review the logs for details.

github-actions[bot] avatar Jun 17 '26 13:06 github-actions[bot]

/review

AlesProkop avatar Jun 18 '26 06:06 AlesProkop

⚠️ 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.

github-actions[bot] avatar Jun 18 '26 06:06 github-actions[bot]

/review

OvesN avatar Jun 19 '26 11:06 OvesN

⚠️ 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.

github-actions[bot] avatar Jun 19 '26 11:06 github-actions[bot]