-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Revise TryGetProjectOrSolutionFilePath
and GetSolutionFilePaths
logic for the new dotnet test experience
#47635
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
Comments
For fixing GetSolutionFilePaths, good catch. I will fix it. However, when we have both |
Interesting. @rainersigwald Are the rules for what to consider documented somewhere? I'm wondering if some of the current behavior are only for backcompat reasons. Maybe we could consider some scenarios as "ambiguous" and do error for the new |
I'm re-opening as the second part of this issue wasn't addressed. Ping @rainersigwald @baronfel for what rules we should follow here. |
Ping @rainersigwald |
It looks like the logic here should be more complicated if we want to match MSBuild. For example, when one project and one solution exists in the directory, the behavior differs depending on whether the file names (without the extension for sure) are the same or not. There is more logic around this piece of code as well. |
@dsplaisted Is there a logic in SDK already somewhere that matches MSBuild in this regard? |
@Youssef1313 It looks like we have that here:
It doesn't look like it's written to be used from other code, so probably if you need this logic it should be factored out in order to be reusable. |
Actually, it looks like that function doesn't do exactly what you're looking for, it will return an arbitrary project in the solution if it locates a solution instead of returning the solution itself. But the functionality you are looking for could probably be factored out. |
Hmm, the logic you linked doesn't seem to match what I linked from MSBuild :/ I think we always want to ensure the two behaviors match exactly so that cases where people do
are guaranteed to work as expected (both build and test command operate on the exact same set of projects) |
@Youssef1313 if there is no sln/slnx and there is only a project file and slnf then use project file. This is what we do in MSBuild |
@surayya-MS Is there a logic exposed somewhere via a public API that we can use here? It will be a bit unfortunate to duplicate all the logic in MSBuild here. |
@Youssef1313 unfortunately, there is no public API for this. The only option for now is to implement the same logic on your side. We could potentially add this to public API in the future. That needs more discussion. |
sdk/src/Cli/dotnet/commands/dotnet-test/SolutionAndProjectUtility.cs
Lines 87 to 88 in 9f73261
The second line above should crash. An array is fixed-length. It's implicitly converted to
ICollection<string>
in that code path and should throw some exception at run-time.sdk/src/Cli/dotnet/commands/dotnet-test/SolutionAndProjectUtility.cs
Lines 19 to 83 in 9f73261
I'm reading this logic as "If there are no sln/slnx files at all, and a single project file is found, use the project file". But what if the directory has slnf and project file, without sln/slnx? I think we should either prefer the slnf, or error. It's a pattern I have never seen, but ...
Anyways, we should validate the behavior of
dotnet build
, and make sure we match it, and share some common helpers if needed.The text was updated successfully, but these errors were encountered: