{"record":{"id":"a2f8a7ccfef8aecc","repo":"dotnet/BenchmarkDotNet","slug":"found-more-than-one-matching-project-file-for-pro","errorCode":null,"errorMessage":"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.","messagePattern":"Found more than one matching project file for (.+?) in (.+?) and its subfolders: '(.+?)','(.+?)'\\. Benchmark project names needs to be unique\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs","lineNumber":437,"sourceCode":"            || directory.Name.StartsWith(\".\", StringComparison.Ordinal)\n#if NETSTANDARD2_0\n            || directory.Attributes.HasFlag(FileAttributes.Hidden)\n            || directory.Attributes.HasFlag(FileAttributes.ReparsePoint)\n#endif\n            ;\n\n        public static FileInfo FindProjectFile(DirectoryInfo rootDirectory, string projectName)\n        {\n            var projectFiles = EnumerateProjectFiles(rootDirectory, projectName);\n\n            // Take first 2 items for performance reasons\n            var files = projectFiles.Take(2).ToArray();\n            return files.Length switch\n            {\n                1 => files[0],\n                0 => throw new NotSupportedException(\n                    $\"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\"),\n                _ => throw new NotSupportedException(\n                    $\"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.\"),\n            };\n        }\n\n        private static IEnumerable<FileInfo> EnumerateProjectFiles(DirectoryInfo rootDirectory, string projectName)\n        {\n            var stack = new Stack<DirectoryInfo>();\n            stack.Push(rootDirectory);\n\n            while (stack.Count > 0)\n            {\n                var currentDir = stack.Pop();\n\n                // 1. Search '*.proj' files in the current directory\n                IEnumerable<FileInfo> files = EnumerateProjectFiles(currentDir);\n\n                foreach (var file in files)\n                {","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/dotnet/BenchmarkDotNet/blob/b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3/src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs#L419-L455","documentation":"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.","triggerScenarios":"Thrown at src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs:437 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3","analyzedAt":"2026-08-13T19:12:24.196Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}