dotnet/BenchmarkDotNet · error · NotSupportedException

The full benchmark name: "{fileName}" combined with artifact

Error message

The full benchmark name: "{fileName}" combined with artifacts path: "{details.Config.ArtifactsPath}" is too long. Please set the value of config.ArtifactsPath to shorter path or rename the type or method.

What it means

ArtifactFileNameHelper throws NotSupportedException when the assembled output file path exceeds the platform length limit. The check guards Windows MAX_PATH-style constraints so diagnoser/exporter artifacts can actually be written. The message identifies the offending benchmark name and ArtifactsPath and tells you to shorten one of them.

Source

Thrown at src/BenchmarkDotNet/Helpers/ArtifactFileNameHelper.cs:62

            return GetFilePath(fileName, details, subfolder, creationTime, fileExtension);
        }

        private static string GetLimitedFilePath(DiagnoserActionParameters details, string? subfolder, DateTime? creationTime, string fileExtension, int limit)
        {
            string shortTypeName = FolderNameHelper.ToFolderName(details.BenchmarkCase.Descriptor.Type, includeNamespace: false);
            string methodName = details.BenchmarkCase.Descriptor.WorkloadMethod.Name;
            string parameters = details.BenchmarkCase.HasParameters
                ? $"-hash{Hashing.HashString(FullNameProvider.GetMethodName(details.BenchmarkCase))}"
                : string.Empty;

            string fileName = $@"{shortTypeName}.{methodName}{parameters}";

            string finalResult = GetFilePath(fileName, details, subfolder, creationTime, fileExtension);

            if (finalResult.Length > limit)
            {
                throw new NotSupportedException($"The full benchmark name: \"{fileName}\" combined with artifacts path: \"{details.Config.ArtifactsPath}\" is too long. " +
                   $"Please set the value of {nameof(details.Config)}.{nameof(details.Config.ArtifactsPath)} to shorter path or rename the type or method.");
            }

            return finalResult;
        }

        private static string GetFilePath(string fileName, DiagnoserActionParameters details, string? subfolder, DateTime? creationTime, string fileExtension)
        {
            // if we run for more than one toolchain, the output file name should contain the name too so we can differ net462 vs net8.0 etc
            if (details.Config.GetJobs().Select(job => ToolchainExtensions.GetToolchain(job)).Distinct().Count() > 1)
                fileName += $"-{details.BenchmarkCase.Job.Environment.Runtime?.Name ?? details.BenchmarkCase.GetToolchain()?.Name ?? details.BenchmarkCase.Job.Id}";

            if (creationTime.HasValue)
                fileName += $"-{creationTime.Value.ToString(BenchmarkRunnerClean.DateTimeFormat)}";

            fileName = FolderNameHelper.ToFolderName(fileName);

            if (!string.IsNullOrEmpty(fileExtension))

View on GitHub (pinned to b515068b61)

Solutions

  1. Set config.ArtifactsPath to a shorter path (e.g. a drive root like C:\bdn or /tmp/bdn).
  2. Shorten the benchmark type and/or method name.
  3. Reduce the number of parameters/arguments so the generated filename is shorter.
  4. On Windows, enable long-path support (LongPathsEnabled) as a secondary mitigation, though shortening is the robust fix.

Example fix

// before
config.ArtifactsPath = @"C:\Users\very\long\deeply\nested\directory\benchmarks";

// after
config.ArtifactsPath = @"C:\bdn";
Defensive patterns

Strategy: validation

Validate before calling

// estimate the worst-case path length before running
var approx = Path.Combine(config.ArtifactsPath, typeName, methodName);
if (approx.Length > 200) config.ArtifactsPath = @"C:\bdn";

Try / catch

try { runner.Run(); }
catch (NotSupportedException ex) when (ex.Message.Contains("too long")) { config.ArtifactsPath = shortPath; /* retry */ }

Prevention

When it happens

Trigger: The final artifact path (ArtifactsPath + folder + type.method + parameter hash + toolchain suffix + extension) exceeds the configured length limit, triggering the guard before a write is attempted.

Common situations: Long benchmark class/method names, deeply nested namespaces, very long ArtifactsPath, many parameter combinations producing long hash suffixes, or running on Windows where path limits bite first.

Related errors


AI-assisted analysis of dotnet/BenchmarkDotNet@b515068b61 (2026-08-13). Data as JSON: /api/errors/d8cec65e9ce0bcd1. Report an issue: GitHub.