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
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Hosting/TestHost/src/WebHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@
/// <param name="solutionName">The name of the solution file to make the content root relative to.</param>
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]
public static IWebHostBuilder UseSolutionRelativeContentRoot(

Check failure on line 126 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux x64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L126

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(126,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 126 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: macOS arm64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L126

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(126,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 126 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L126

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(126,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 126 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: macOS x64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L126

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(126,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 126 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L126

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(126,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 126 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L126

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(126,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 126 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl x64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L126

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(126,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 126 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L126

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(126,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 126 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: Ubuntu x64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L126

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(126,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 126 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: Ubuntu x64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L126

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(126,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 126 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: macOS)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L126

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(126,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 126 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: macOS)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L126

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(126,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 126 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L126

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(126,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 126 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L126

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(126,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)
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?

{
return builder.UseSolutionRelativeContentRoot(solutionRelativePath, AppContext.BaseDirectory, solutionName);
}
Expand All @@ -140,11 +140,11 @@
/// <param name="solutionName">The name of the solution file to make the content root relative to.</param>
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]
public static IWebHostBuilder UseSolutionRelativeContentRoot(

Check failure on line 143 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux x64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L143

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(143,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 143 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: macOS arm64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L143

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(143,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 143 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L143

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(143,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 143 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: macOS x64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L143

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(143,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 143 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L143

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(143,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 143 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L143

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(143,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 143 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl x64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L143

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(143,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 143 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L143

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(143,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 143 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: Ubuntu x64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L143

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(143,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 143 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: Ubuntu x64)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L143

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(143,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 143 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: macOS)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L143

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(143,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 143 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: macOS)

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L143

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(143,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 143 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L143

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(143,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 143 in src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs#L143

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs(143,35): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'UseSolutionRelativeContentRoot' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)
this IWebHostBuilder builder,
string solutionRelativePath,
string applicationBasePath,
string solutionName = "*.sln")
string solutionName = "*.sln?")
{
ArgumentNullException.ThrowIfNull(solutionRelativePath);
ArgumentNullException.ThrowIfNull(applicationBasePath);
Expand Down
Loading