Skip to content
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

WorkloadRestoreCommand.DiscoverAllProjects: Return full paths #47415

Merged
merged 2 commits into from
Mar 10, 2025

Conversation

edvilme
Copy link
Member

@edvilme edvilme commented Mar 10, 2025

Fixes #47390

When running dotnet workload restore ../foo.sln, the project paths in the sln file are evaluated based on the current directory instead of the sln directory. To avoid this, WorkloadRestoreCommand.DiscoverAllProjects should return full paths instead of relative paths

image

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Workloads untriaged Request triage from a team member labels Mar 10, 2025
@edvilme edvilme marked this pull request as ready for review March 10, 2025 16:48
@edvilme edvilme requested a review from a team March 10, 2025 16:48
Copy link
Member

@nagilson nagilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks good to me, nice find! It would be nice to have a test, though I understand this is a small, well-scoped problem and honestly a quirky bug that would not necessarily happen again if coded correctly. Curious what others think on the importance of a test.

@Forgind
Copy link
Member

Forgind commented Mar 10, 2025

This doesn't look unreasonable, but if this worked in 9.0.100, can you explain what regressed this? I suspect this may paper over a problem instead of resolving one.

@nagilson
Copy link
Member

This doesn't look unreasonable, but if this worked in 9.0.100, can you explain what regressed this? I suspect this may paper over a problem instead of resolving one.

That's a good point. I assume it's possible that a change to the sln library caused this in 9.0.200, but I don't really know enough to say so I'm curious about this too.

@edvilme
Copy link
Member Author

edvilme commented Mar 10, 2025

This doesn't look unreasonable, but if this worked in 9.0.100, can you explain what regressed this? I suspect this may paper over a problem instead of resolving one.

It is not related to vs-solutionpersistence itself, but rather to the refactorings done on #45442 to remove SlnFile 😟

@edvilme edvilme enabled auto-merge (squash) March 10, 2025 17:27
@edvilme edvilme merged commit d8512e1 into dotnet:release/9.0.2xx Mar 10, 2025
30 checks passed
@Forgind
Copy link
Member

Forgind commented Mar 10, 2025

Can you be more specific on which part of that change led to this issue?

@edvilme
Copy link
Member Author

edvilme commented Mar 10, 2025

@Forgind yes, instead of resolving the project paths to be absolute paths, the refactoring resolved the relative paths instead.

image

@Forgind
Copy link
Member

Forgind commented Mar 10, 2025

Do you need to have filtered out SolutionFolders there?

Also, I think that instead of this fix, we should instead make that return absolute paths. Otherwise I'd be concerned that other places may be affected.

@edvilme
Copy link
Member Author

edvilme commented Mar 10, 2025

Do you need to have filtered out SolutionFolders there?

In the old parser, a Solution Folder is considered a special type of project. In this case.

var projects = solutionFilesInOrder.Where(p => p.ProjectType != SolutionProjectType.SolutionFolder);

is equivalent to

var projects = solutionFile.SolutionProjects

in the new parser

Also, I think that instead of this fix, we should instead make that return absolute paths. Otherwise I'd be concerned that other places may be affected.

You mean p.FilePath? SlnFileFactory.CreateFromFileOrDirectory returns a SolutionProjectModel which is owned by the vs-solutionpersistence team. Also, it returns relative paths as they are stored that way in the solution files

@Forgind
Copy link
Member

Forgind commented Mar 10, 2025

You mean p.FilePath? SlnFileFactory.CreateFromFileOrDirectory returns a SolutionProjectModel which is owned by the vs-solutionpersistence team. Also, it returns relative paths as they are stored that way in the solution files

Yeah, so instead of p.FilePath, it would be like Path.GetFullPath(p.FilePath) or whatever.

@Forgind
Copy link
Member

Forgind commented Mar 10, 2025

I talked with edvilme a bit more offline, and we looked into other places where this gets used, and they should all be fine with the relative or absolute paths, so this change should suffice to resolve the change in behavior, so I'm satisfied. Thanks for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Workloads untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants