Skip to content

Search for slnx files when setting solution-relative content root #61305

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kimsey0
Copy link
Contributor

@kimsey0 kimsey0 commented Apr 3, 2025

Search for slnx files when setting solution-relative content root

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Fixes #61304

@ghost ghost added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Apr 3, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Apr 3, 2025
Copy link
Contributor

Thanks for your PR, @@kimsey0. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@@ -126,7 +126,7 @@ public static IWebHostBuilder ConfigureTestContainer<TContainer>(this IWebHostBu
public static IWebHostBuilder UseSolutionRelativeContentRoot(
this IWebHostBuilder builder,
string solutionRelativePath,
string solutionName = "*.sln")
string solutionName = "*.sln?")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This probably isn't a good idea, since it also matches solution filter files (.slnf).

Copy link

@ninety7 ninety7 May 14, 2025

Choose a reason for hiding this comment

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

I can think of a few options:

  1. Add another overload for the UseSolutionRelativeContentRoot method that takes in a list of solutionNames and default to ["*.sln", "*.slnx"]. Then we make different calls to Directory.EnumerateFiles and stop on the first return.
  2. If the solutionName param is *.sln and the EnumerateFiles call does not return, do an extra lookup for *.slnx.
  3. The inverse of 2, and defaulting the parameter to *.slnx.
  4. Use your new default of *.sln? and filter solution filter files (.slnf) or any other than .sln, .slnx, if solutionName has the default value.

I think I like option 3 the most.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem with 1 is that, since the parameters are both optional, there will be a conflict between the overloads. That could maybe be solved with OverloadResolutionPriorityAttribute, but that only works from .NET 9.

2 and 3 are a little weird, since the parameter that you pass in doesn't match the behavior.

Copy link

Choose a reason for hiding this comment

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

2 and 3 are a bit weird, but even if it's not explicit, sln and slnx are analogous. Maybe do 2 and 3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebApplicationFactory doesn't set solution relative content root if you switch to slnx solution
2 participants