Skip to content

Commit

Permalink
Make ProjectLocator fall back to other locators if enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Genbox committed Jan 2, 2025
1 parent 39791f7 commit 94aa84c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/BenchmarkDotNet/Locators/ProjectLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public FileInfo Locate(DirectoryInfo rootDirectory, Type type)

if (projectFiles.Length == 0)
{
throw new NotSupportedException(
$"Unable to find {projectName} in {rootDirectory.FullName} and its subfolders. Most probably the name of output exe is different than the name of the .(c/f)sproj");
return null;
}
else if (projectFiles.Length > 1)

if (projectFiles.Length > 1)
{
throw new NotSupportedException(
$"Found more than one matching project file for {projectName} in {rootDirectory.FullName} and its subfolders: {string.Join(",", projectFiles.Select(pf => $"'{pf.FullName}'"))}. Benchmark project names needs to be unique.");
Expand Down
3 changes: 3 additions & 0 deletions src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ protected virtual FileInfo GetProjectFilePath(BenchmarkCase benchmark, ILogger l

var path = locator.Locate(rootDirectory, benchmarkTarget);

if (path == null)
continue;

if (path.Exists)
return path;

Expand Down

0 comments on commit 94aa84c

Please sign in to comment.