-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix slnf path separator handling to support both Unix and Windows style paths #12730
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
Conversation
|
Hello @@copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo. |
Co-authored-by: baronfel <[email protected]>
…le paths on all platforms Co-authored-by: baronfel <[email protected]>
Co-authored-by: baronfel <[email protected]>
Co-authored-by: baronfel <[email protected]>
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 pull request adds platform-independent path separator normalization for solution filter files to support cross-platform development scenarios. The change ensures that solution filter files work correctly regardless of which path separator style (forward or backslashes) is used on any operating system.
- Introduces a new
NormalizePathSeparatorsToForwardSlashmethod that always normalizes paths to forward slashes - Replaces platform-dependent
FixFilePathwith the new method in solution filter path handling - Adds comprehensive tests for Unix-style, Windows-style, and mixed path separators in solution filters
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Shared/FileUtilities.cs | Adds NormalizePathSeparatorsToForwardSlash method for platform-independent path normalization |
| src/Build/Construction/Solution/SolutionFile.cs | Updates solution filter path handling to use the new normalization method in three locations |
| src/Build.UnitTests/Construction/SolutionFilter_Tests.cs | Adds comprehensive test coverage for different path separator styles in solution filters |
…n Unix Co-authored-by: YuliiaKovalova <[email protected]>
Youssef1313
left a comment
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.
Note: I have seen this during working on dotnet/sdk#51411, fixed by Copilot in a sub-PR dotnet/sdk#51770
|
@baronfel As part of this, can you also please double check the behavior of |
@copilot.can you check this please |
The changes in this PR are specific to MSBuild's If To verify if there's an issue with |
Co-authored-by: YuliiaKovalova <[email protected]>
Fix slnf path separator handling to support both Unix and Windows style paths on all platforms
Problem
Solution filter (.slnf) files require Windows-style directory separators (
\) to work correctly on all platforms. When a .slnf uses Unix-style paths (/) and the solution uses Windows-style paths (\), or vice versa, MSBuild throws an error saying the project is not in the solution.Root Cause
The code was using
FileUtilities.FixFilePath()which is platform-dependent:/to\)\to/This caused mismatches when comparing paths with different separator styles.
Solution
Added
FileUtilities.NormalizePathSeparatorsToForwardSlash(): A new platform-independent method that always converts all path separators to forward slashes for consistent comparison.Updated path comparison logic: Modified
ValidateProjectsInSolutionFilter(),ParseSolutionFilter(), andProjectShouldBuild()to use the new normalization method directly, ensuring paths are compared consistently regardless of which separator style is used.Added comprehensive tests: Created three new test methods covering:
Changes
src/Shared/FileUtilities.cs: AddedNormalizePathSeparatorsToForwardSlash()method with simple, platform-independent implementationsrc/Build/Construction/Solution/SolutionFile.cs: Updated to use normalized path comparisonsrc/Build.UnitTests/Construction/SolutionFilter_Tests.cs: Added comprehensive tests with shared helper methodTesting
Fixes #10806
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.