-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[release/10.0] Fix path separator issue on Linux/macOS in dotnet-ef tools #37519
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
base: release/10.0
Are you sure you want to change the base?
Conversation
Normalize Windows-style backslash paths returned by MSBuild to use the correct directory separator for the current platform when constructing output paths in Project.FromFile(). Co-authored-by: AndriySvyryd <[email protected]>
src/dotnet-ef/Project.cs
Outdated
| AssemblyName = properties[nameof(AssemblyName)], | ||
| DesignAssembly = designAssembly, | ||
| Language = properties[nameof(Language)], | ||
| OutputPath = properties[nameof(OutputPath)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Also move the similar path-normalizing logic from RootCommand.cs to this file so that it's applied consistently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the path normalization to Project.FromFile() where the OutputPath property is set. This normalizes the path once at the source, so RootCommand.cs no longer needs its own normalization logic. Commit: 8796083
Move path normalization for OutputPath to Project.FromFile() so that the OutputPath property is already normalized when used in RootCommand.cs. This removes duplicated path normalization logic. Co-authored-by: AndriySvyryd <[email protected]>
|
@copilot Update progress by rewriting the PR summary using this template: |
... Updated the PR description with the servicing template. |
There was a problem hiding this 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 fixes a critical path separator issue in the dotnet-ef command-line tools on Linux/macOS. MSBuild returns Windows-style backslashes in the OutputPath property even on non-Windows platforms, which causes incorrect directory creation and subsequent build failures. The fix normalizes the path separator earlier in the pipeline (when reading from MSBuild in Project.cs) rather than at usage points, ensuring all consumers receive correctly-normalized paths.
Changes:
- Moved path separator normalization from
RootCommand.cstoProject.cswhere theOutputPathis first read from MSBuild - Normalized
OutputPathis now stored in theProjectobject, eliminating the need for normalization at usage points - Fixed the
CopyBuildHostoperation which was previously receiving paths with incorrect separators
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/dotnet-ef/RootCommand.cs | Removed redundant path separator normalization since OutputPath is now normalized upstream |
| src/dotnet-ef/Project.cs | Added path separator normalization when reading OutputPath from MSBuild and storing it in the Project object |
Description
MSBuild returns Windows-style backslashes in the
OutputPathproperty (e.g.,bin\Debug\net10.0\), even when running on Linux/macOS. When this path is combined with theProjectDirpath usingPath.CombineandPath.GetFullPath, the resulting path contains backslashes on non-Windows platforms. This causes incorrect directory creation (e.g., a directory namedbin\Debuginstead ofbin/Debug) which then leads to build failures when subsequent operations try to find files using the correct platform-specific paths.There was logic to normalize this, but it wasn't applied to the BuildHost target folder.
Customer impact
Any customer using dotnet-ef tools 10.0.2 on Linux/macOS will encounter build failures when running
dotnet ef.The workaround is to first build the project using
dotnet buildand then use the--no-buildoption when running EF commands.How found
Multiple customer reports on 10.0.2.
Regression
Yes, from 10.0.1. Introduced in PR #37301 which added an
msbuildinvocation to get the target framework.Testing
Tested manually
Risk
Low. Targeted fix that applies the existing logic consistently. Only affects design-time tools.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.