internal static async Task <int> Main(string[] args) { Logger.Log("RunTest command line"); Logger.Log(string.Join(" ", args)); var options = Options.Parse(args); if (options == null) { return(ExitFailure); } ConsoleUtil.WriteLine($"Running '{options.DotnetFilePath} --version'.."); var dotnetResult = await ProcessRunner.CreateProcess( options.DotnetFilePath, arguments : "--version", captureOutput : true ).Result; ConsoleUtil.WriteLine(string.Join(Environment.NewLine, dotnetResult.OutputLines)); ConsoleUtil.WriteLine( ConsoleColor.Red, string.Join(Environment.NewLine, dotnetResult.ErrorLines) ); if (options.CollectDumps) { if (!DumpUtil.IsAdministrator()) { ConsoleUtil.WriteLine( ConsoleColor.Yellow, "Dump collection specified but user is not administrator so cannot modify registry" ); } else { DumpUtil.EnableRegistryDumpCollection(options.LogFilesDirectory); } } try { // Setup cancellation for ctrl-c key presses using var cts = new CancellationTokenSource(); Console.CancelKeyPress += delegate { cts.Cancel(); DisableRegistryDumpCollection(); }; int result; if (options.Timeout is { } timeout) { result = await RunAsync(options, timeout, cts.Token); } else { result = await RunAsync(options, cts.Token); } CheckTotalDumpFilesSize(); return(result); }