Skip to content

OutPut the PathTooLong when when longpath is disabled #11731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 7, 2025

Conversation

JaynieBai
Copy link
Member

@JaynieBai JaynieBai commented Apr 15, 2025

Fixes #10201

Context

When build with dotnet sdk 9.0, during evaluation, it can't find the file Program.cs with main function
image

When build with MSBuild.exe, it has the following error
image

Changes Made

Throw the PathTooLongException exception in windows when the file path exceeds the maximum length
Catch the exception when evaluation and processing the msbuild.exe command.

Testing

image

image

Notes

@JaynieBai JaynieBai marked this pull request as ready for review April 23, 2025 05:49
Copy link
Contributor

@Copilot 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 introduces a fix for handling long file paths when longpath is disabled by throwing and catching a PathTooLongException in key parts of the MSBuild process.

  • Made IsPathTooLong public so it can be accessed from other components
  • Added a check in WindowsFileSystem to throw a PathTooLongException when a directory path is too long
  • Implemented catch blocks in XMake and Evaluator to handle and log the exception accordingly

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/Shared/FileUtilities.cs Changed IsPathTooLong from private to public to allow external use
src/Shared/FileSystem/WindowsFileSystem.cs Added a conditional check that throws a PathTooLongException if the path exceeds the maximum allowed length
src/MSBuild/XMake.cs Added a catch block for PathTooLongException which writes the error message to the console
src/Build/Evaluation/Evaluator.cs Added a catch block for PathTooLongException which logs the error message during evaluation
Comments suppressed due to low confidence (1)

src/Build/Evaluation/Evaluator.cs:351

  • [nitpick] Consider including additional context in the error log to help with debugging long path issues instead of logging only the exception message.
ex.Message

@JaynieBai JaynieBai self-assigned this Apr 23, 2025
@JaynieBai JaynieBai requested a review from surayya-MS May 7, 2025 08:12
@surayya-MS surayya-MS merged commit 695b1ef into dotnet:main May 7, 2025
10 checks passed
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.

[Bug]: Project file does not exist with LongPaths
3 participants