dotnet/BenchmarkDotNet · error · NotSupportedException

Unable to find {projectName} in {rootDirectory.FullName} and

Error message

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

What it means

CsProjGenerator searches rootDirectory recursively for a project whose file name matches the expected benchmark output name; it fails when no matching .csproj/.fsproj exists.

Source

Thrown at src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs:435

        private static bool ShouldIgnoreDirectory(DirectoryInfo directory)
            => IgnoredDirectoryNames.Contains(directory.Name)
            || 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);

View on GitHub (pinned to b515068b61)

Solutions

  1. Make sure the output assembly name matches the project file name (the .csproj/.fsproj), or pass the correct project name explicitly.
  2. Check that the project file actually exists under the given root directory or one of its subfolders.
  3. Use an absolute rootDirectory that contains the benchmark project.

When it happens

Trigger: Thrown at src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs:435 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/04848cd8e0510d38. Report an issue: GitHub.