Skip to content

Commit

Permalink
Fix: print out errors before starting self-update
Browse files Browse the repository at this point in the history
  • Loading branch information
kayone committed May 8, 2019
1 parent 58d2749 commit cd12d68
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 47 deletions.
1 change: 0 additions & 1 deletion src/AppGet/AppGet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
<Compile Include="AppData\Config.cs" />
<Compile Include="AppData\InstalledPackagesStore.cs" />
<Compile Include="AppData\StoreBase.cs" />
<Compile Include="Application.cs" />
<Compile Include="CommandLine\ConsoleEventReporter.cs" />
<Compile Include="CommandLine\ConsoleTable.cs" />
<Compile Include="CommandLine\TableHelper.cs" />
Expand Down
37 changes: 32 additions & 5 deletions src/AppGet/AppGetConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
using AppGet.CommandLine;
using AppGet.Commands;
using AppGet.Exceptions;
using AppGet.Infrastructure.Composition;
using AppGet.Infrastructure.Logging;
using AppGet.PackageRepository;
using AppGet.Update;
using DryIoc;
using NLog;

namespace AppGet
Expand All @@ -29,14 +33,33 @@ public static int Main(string[] args)

private static async Task<int> Run(string[] args)
{
IAppGetUpdateService updatedService = null;

try
{
var container = ContainerBuilder.Container;

LogConfigurator.EnableConsoleTarget(LogConfigurator.FriendlyLayout, LogLevel.Info);
LogConfigurator.EnableSentryTarget("https://aa5e806801bc4d4f99a6112160128dbe@sentry.appget.net/7");
LogConfigurator.EnableFileTarget(LogLevel.Trace);

try
{
updatedService = container.Resolve<IAppGetUpdateService>();
updatedService.Start();
}
catch (Exception e)
{
Logger.Error(e, "Failed to initilize update service.");
}

if (Debugger.IsAttached && !args.Any())
{
args = TakeArgsFromInput().SkipWhile(c=>c.ToLowerInvariant() == "appget").ToArray();
args = TakeArgsFromInput().SkipWhile(c => c.ToLowerInvariant() == "appget").ToArray();
}

await Application.Execute(args);
var commandExecutor = container.Resolve<ICommandExecutor>();
await commandExecutor.ExecuteCommand(args);
return 0;
}
catch (CommandLineParserException)
Expand Down Expand Up @@ -72,11 +95,15 @@ private static async Task<int> Run(string[] args)
Logger.Fatal(ex, null);
return 1;
}
finally
{
if (updatedService != null)
{
await updatedService.Commit();
}
}
}




private static string[] TakeArgsFromInput()
{
Console.WriteLine("");
Expand Down
40 changes: 0 additions & 40 deletions src/AppGet/Application.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/AppGet/NexClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public async Task SubmitReport(InstallerReport report)
};

await _httpClient.SendAsync(request, TimeSpan.FromSeconds(5));

}
catch (Exception e)
{
Expand Down

0 comments on commit cd12d68

Please sign in to comment.