Skip to content

Commit 6c36f55

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

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/BenchmarkDotNet/Running/BuildPartition.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ public BuildPartition(BenchmarkBuildInfo[] benchmarks, IResolver resolver)
3333
string folderInfo = RepresentativeBenchmarkCase.Job.FolderInfo;
3434
int id = Interlocked.Increment(ref s_partitionCounter);
3535
ProgramName = $"{benchmarkAssemblyName}-{folderInfo}-{id}";
36+
// Very long program name can cause the path to exceed Window's 260 character limit,
37+
// for example BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.
38+
// 36 is an arbitrary limit, but it's the length of Guid strings which is what was used previously.
39+
if (ProgramName.Length > 36)
40+
{
41+
ProgramName = $"{benchmarkAssemblyName}-{id}";
42+
if (ProgramName.Length > 36)
43+
{
44+
ProgramName = $"{folderInfo}-{id}";
45+
ProgramName = id.ToString();
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)