-
Notifications
You must be signed in to change notification settings - Fork 2
/
Program.cs
50 lines (46 loc) · 1.57 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.IO;
using System.Threading.Tasks;
using KP_Steam_Uploader.Command;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Extensions.Logging;
namespace KP_Steam_Uploader
{
class Program
{
private static async Task<int> Main(string[] args)
{
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(AppDomain.CurrentDomain.BaseDirectory + "\\appsettings.json", false, false)
.AddEnvironmentVariables()
.Build();
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.Enrich.FromLogContext()
.CreateLogger();
var builder = new HostBuilder()
.ConfigureServices((hostContext, services) =>
{
services.AddLogging(config =>
{
config.ClearProviders();
config.AddProvider(new SerilogLoggerProvider(Log.Logger));
});
});
try
{
return await builder.RunCommandLineApplicationAsync<KpSteamCommand>(args);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
return 1;
}
}
}
}