Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 3446715

Browse files
authored
fix(exam-management): fix build (#525)
After merging PR #491, the service was not building. **LEASON:** Always build the solution manually before accepting the PR. The author may not build the project and submit PR
1 parent a907392 commit 3446715

3 files changed

Lines changed: 25 additions & 13 deletions

File tree

src/Services/ExamManagement/ExamManagement.API/ExamManagement.API.csproj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Serilog" Version="2.10.0" />
9-
<PackageReference Include="Serilog.Enrichers.Span" Version="1.3.0" />
10-
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0" />
8+
<!-- Logging -->
9+
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0"/>
10+
<PackageReference Include="Serilog.Enrichers.Span" Version="1.2.0"/>
11+
<PackageReference Include="Serilog.Sinks.Seq" Version="5.0.1"/>
12+
13+
<!-- Swagger -->
1114
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
1215
</ItemGroup>
1316

src/Services/ExamManagement/ExamManagement.API/Program.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.IO;
14
using Microsoft.AspNetCore.Hosting;
5+
using Microsoft.Extensions.Configuration;
26
using Microsoft.Extensions.Hosting;
37
using Serilog;
48
using Serilog.Enrichers.Span;
59

610
namespace ExamManagement.API
711
{
8-
public class Program
12+
public static class Program
913
{
1014
public static readonly string Namespace = typeof(Program).Namespace!;
11-
public static readonly string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1);
15+
public static readonly string AppName = Namespace[(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1)..];
1216

1317
[System.Diagnostics.CodeAnalysis.SuppressMessage(
1418
"Design",
1519
"CA1031:Do not catch general exception types",
1620
Justification = "Top level all exception catcher")]
17-
public static void Main(string[] args)
21+
public static int Main(string[] args)
1822
{
1923
Activity.DefaultIdFormat = ActivityIdFormat.W3C;
20-
24+
2125
var configuration = GetConfiguration();
2226

2327
Log.Logger = CreateSerilogLogger(configuration);
2428
try
2529
{
2630
Log.Information("Configuring web host ({ApplicationContext})...", AppName);
27-
CreateHostBuilder(args).Build().Run();
31+
CreateHostBuilder(configuration, args).Build().Run();
2832

2933
return 0;
3034
}
@@ -39,7 +43,7 @@ public static void Main(string[] args)
3943
}
4044
}
4145

42-
public static IHostBuilder CreateHostBuilder(IConfiguration configuration,string[] args) =>
46+
public static IHostBuilder CreateHostBuilder(IConfiguration configuration, string[] args) =>
4347
Host.CreateDefaultBuilder(args)
4448
.ConfigureWebHostDefaults(webBuilder =>
4549
{
@@ -69,6 +73,6 @@ private static IConfiguration GetConfiguration()
6973
.AddEnvironmentVariables();
7074

7175
return builder.Build();
72-
}
76+
}
7377
}
7478
}

src/Services/ExamManagement/ExamManagement.API/Startup.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.Extensions.Configuration;
44
using Microsoft.Extensions.DependencyInjection;
55
using Microsoft.Extensions.Hosting;
6+
using Microsoft.Extensions.Logging;
67
using Microsoft.OpenApi.Models;
78
using Serilog;
89

@@ -20,28 +21,32 @@ public Startup(IConfiguration configuration)
2021
// This method gets called by the runtime. Use this method to add services to the container.
2122
public void ConfigureServices(IServiceCollection services)
2223
{
23-
2424
services.AddControllers();
2525
services.AddSwaggerGen(c =>
2626
{
2727
c.SwaggerDoc("v1", new OpenApiInfo { Title = "ExamManagement.API", Version = "v1" });
2828
});
2929
}
3030

31-
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
31+
public void Configure(
32+
IApplicationBuilder app,
33+
IWebHostEnvironment env,
34+
ILoggerFactory loggerFactory)
3235
{
3336
var pathBase = Configuration["PATH_BASE"];
3437
if (!string.IsNullOrEmpty(pathBase))
3538
{
3639
loggerFactory.CreateLogger<Startup>().LogInformation("Using PATH BASE '{pathBase}'", pathBase);
3740
app.UsePathBase(pathBase);
3841
}
39-
42+
4043
if (env.IsDevelopment())
4144
{
4245
app.UseDeveloperExceptionPage();
4346
}
47+
4448
app.UseSerilogRequestLogging();
49+
4550
app.UseSwagger();
4651
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "ExamManagement.API v1"));
4752

0 commit comments

Comments
 (0)