Skip to content

Commit 65ceb47

Browse files
authored
quick, low-effort binlog upload when created by commands deriving from DotnetCommand (#49513)
1 parent eb6fe8e commit 65ceb47

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Cli/Microsoft.DotNet.Cli.Utils/ExponentialRetry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static async Task<T> ExecuteAsyncWithRetry<T>(Func<Task<T>> action,
5555
return result;
5656
}
5757
}
58-
throw new Exception("Timer should not be exhausted");
58+
throw new Exception($"Timer for task {taskDescription} should not be exhausted.");
5959
}
6060

6161
public static async Task<T> ExecuteWithRetry<T>(Func<T> action,

test/Microsoft.NET.TestFramework/Commands/TestCommand.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public virtual CommandResult Execute(IEnumerable<string> args)
166166
{
167167
command.StandardOutputEncoding(StandardOutputEncoding);
168168
}
169-
169+
170170
string fileToShow = Path.GetFileNameWithoutExtension(spec.FileName!).Equals("dotnet", StringComparison.OrdinalIgnoreCase) ?
171171
"dotnet" :
172172
spec.FileName!;
@@ -176,6 +176,15 @@ public virtual CommandResult Execute(IEnumerable<string> args)
176176
var result = ((Command)command).Execute(ProcessStartedHandler);
177177
Log.WriteLine($"Command '{display}' exited with exit code {result.ExitCode}.");
178178

179+
if (Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT") is string uploadRoot)
180+
{
181+
var binlogFiles = Directory.GetFiles(spec.WorkingDirectory ?? Environment.CurrentDirectory, "*.binlog");
182+
foreach (string binlogFile in binlogFiles)
183+
{
184+
File.Copy(binlogFile, Path.Combine(uploadRoot, Path.GetFileName(binlogFile)), true);
185+
}
186+
}
187+
179188
return result;
180189
}
181190

0 commit comments

Comments
 (0)