dotnet/BenchmarkDotNet · error · NotSupportedException
Found more than one matching project file for {projectName}
Error message
Found more than one matching project file for {projectName} in {rootDirectory.FullName} and its subfolders: '{files[0].FullName}','{files[1].FullName}'. Benchmark project names needs to be unique. What it means
CsProjGenerator requires benchmark project names to be unique under rootDirectory; finding two or more project files with the same name is ambiguous and aborts the build.
Source
Thrown at src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs:437
|| directory.Name.StartsWith(".", StringComparison.Ordinal)
#if NETSTANDARD2_0
|| directory.Attributes.HasFlag(FileAttributes.Hidden)
|| directory.Attributes.HasFlag(FileAttributes.ReparsePoint)
#endif
;
public static FileInfo FindProjectFile(DirectoryInfo rootDirectory, string projectName)
{
var projectFiles = EnumerateProjectFiles(rootDirectory, projectName);
// Take first 2 items for performance reasons
var files = projectFiles.Take(2).ToArray();
return files.Length switch
{
1 => files[0],
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"),
_ => throw new NotSupportedException(
$"Found more than one matching project file for {projectName} in {rootDirectory.FullName} and its subfolders: '{files[0].FullName}','{files[1].FullName}'. Benchmark project names needs to be unique."),
};
}
private static IEnumerable<FileInfo> EnumerateProjectFiles(DirectoryInfo rootDirectory, string projectName)
{
var stack = new Stack<DirectoryInfo>();
stack.Push(rootDirectory);
while (stack.Count > 0)
{
var currentDir = stack.Pop();
// 1. Search '*.proj' files in the current directory
IEnumerable<FileInfo> files = EnumerateProjectFiles(currentDir);
foreach (var file in files)
{View on GitHub (pinned to b515068b61)
Solutions
- Rename one of the duplicate projects so every benchmark project name is unique within the search tree.
- Narrow the rootDirectory so only one matching project file is found.
- Remove stale copies of the project (e.g. backup folders) from the subfolders being searched.
When it happens
Trigger: Thrown at src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs:437 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of dotnet/BenchmarkDotNet@b515068b61 (2026-08-13).
Data as JSON: /api/errors/a2f8a7ccfef8aecc.
Report an issue: GitHub.