private static async Task ExecuteAsync(Options options) { Options = options; try { ErrorTraceListener errorTraceListener = new ErrorTraceListener(); Trace.Listeners.Add(errorTraceListener); Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); IEnumerable <IDependencyInfo> buildInfos = Options.ProductVersions .Select(kvp => CreateDependencyBuildInfo(kvp.Key, kvp.Value)) .ToArray(); DependencyUpdateResults updateResults = UpdateFiles(buildInfos); if (updateResults.ChangesDetected()) { if (Options.UpdateOnly) { Trace.TraceInformation($"Changes made but no GitHub credentials specified, skipping PR creation"); } else { await CreatePullRequestAsync(); } } if (errorTraceListener.Errors.Any()) { string errors = string.Join(Environment.NewLine, errorTraceListener.Errors); Console.Error.WriteLine("Failed to update dependencies due to the following errors:"); Console.Error.WriteLine(errors); Console.Error.WriteLine(); Console.Error.WriteLine("You may need to use the --compute-shas option if checksum files are missing."); Environment.Exit(1); } } catch (Exception e) { Console.Error.WriteLine($"Failed to update dependencies:{Environment.NewLine}{e}"); Environment.Exit(1); } Environment.Exit(0); }
public static async Task Main(string[] args) { try { ErrorTraceListener errorTraceListener = new ErrorTraceListener(); Trace.Listeners.Add(errorTraceListener); Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); Options.Parse(args); IEnumerable <IDependencyInfo> buildInfos = GetBuildInfo(); DependencyUpdateResults updateResults = UpdateFiles(buildInfos); if (updateResults.ChangesDetected()) { if (Options.UpdateOnly) { Trace.TraceInformation($"Changes made but no GitHub credentials specified, skipping PR creation"); } else { await CreatePullRequestAsync(); } } if (errorTraceListener.Errors.Any()) { string errors = String.Join(Environment.NewLine, errorTraceListener.Errors); Console.Error.WriteLine("Failed to update dependencies due to the following errors:"); Console.Error.WriteLine(errors); Console.Error.WriteLine(); Console.Error.WriteLine("You may need to use the --compute-shas option if checksum files are missing."); Environment.Exit(1); } } catch (Exception e) { Console.Error.WriteLine($"Failed to update dependencies:{Environment.NewLine}{e.ToString()}"); Environment.Exit(1); } Environment.Exit(0); }