Skip to content

Commit e81b9a2

Browse files
committed
Fix Windows path too long.
1 parent cd50f7b commit e81b9a2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/BenchmarkDotNet/Running/BuildPartition.cs

+16
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Threading;
55
using BenchmarkDotNet.Characteristics;
66
using BenchmarkDotNet.Configs;
7+
using BenchmarkDotNet.Detectors;
78
using BenchmarkDotNet.Environments;
89
using BenchmarkDotNet.Helpers;
910
using BenchmarkDotNet.Jobs;
@@ -33,6 +34,21 @@ public BuildPartition(BenchmarkBuildInfo[] benchmarks, IResolver resolver)
3334
string folderInfo = RepresentativeBenchmarkCase.Job.FolderInfo;
3435
int id = Interlocked.Increment(ref s_partitionCounter);
3536
ProgramName = $"{benchmarkAssemblyName}-{folderInfo}-{id}";
37+
// Very long program name can cause the path to exceed Window's 260 character limit,
38+
// for example BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.
39+
// 36 is an arbitrary limit, but it's the length of Guid strings which is what was used previously.
40+
if (OsDetector.IsWindows() && ProgramName.Length > 36)
41+
{
42+
ProgramName = $"{benchmarkAssemblyName}-{id}";
43+
if (ProgramName.Length > 36)
44+
{
45+
ProgramName = $"{folderInfo}-{id}";
46+
if (ProgramName.Length > 36)
47+
{
48+
ProgramName = id.ToString();
49+
}
50+
}
51+
}
3652
LogBuildOutput = benchmarks[0].Config.Options.IsSet(ConfigOptions.LogBuildOutput);
3753
GenerateMSBuildBinLog = benchmarks[0].Config.Options.IsSet(ConfigOptions.GenerateMSBuildBinLog);
3854
}

0 commit comments

Comments
 (0)