Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 5c2b145

Browse files
committed
Commented out local configuration, to avoid exception
1 parent 942fcdf commit 5c2b145

File tree

3 files changed

+44
-14
lines changed

3 files changed

+44
-14
lines changed

src/Web/WebStatus/Program.cs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
using Microsoft.AspNetCore;
22
using Microsoft.AspNetCore.Hosting;
33
using Microsoft.Extensions.Configuration;
4-
using Microsoft.Extensions.Logging;
54
using Serilog;
65
using System;
6+
using System.Collections.Generic;
77
using System.IO;
8+
using System.Linq;
9+
using System.Reflection;
810

911
namespace WebStatus
1012
{
1113
public class Program
1214
{
13-
public static readonly string Namespace = typeof(Program).Namespace;
1415
public static readonly string AppName = Namespace;
16+
public static readonly string Namespace = typeof(Program).Namespace;
1517

1618
public static int Main(string[] args)
1719
{
@@ -24,6 +26,8 @@ public static int Main(string[] args)
2426
Log.Information("Configuring web host ({ApplicationContext})...", AppName);
2527
var host = BuildWebHost(configuration, args);
2628

29+
LogPackagesVersionInfo();
30+
2731
Log.Information("Starting web host ({ApplicationContext})...", AppName);
2832
host.Run();
2933

@@ -83,5 +87,39 @@ private static IConfiguration GetConfiguration()
8387

8488
return builder.Build();
8589
}
90+
91+
private static string GetVersion(Assembly assembly)
92+
{
93+
try
94+
{
95+
return $"{assembly.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version} ({assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion.Split()[0]})";
96+
}
97+
catch
98+
{
99+
return string.Empty;
100+
}
101+
}
102+
103+
private static void LogPackagesVersionInfo()
104+
{
105+
var assemblies = new List<Assembly>();
106+
107+
foreach (var dependencyName in typeof(Program).Assembly.GetReferencedAssemblies())
108+
{
109+
try
110+
{
111+
// Try to load the referenced assembly...
112+
assemblies.Add(Assembly.Load(dependencyName));
113+
}
114+
catch
115+
{
116+
// Failed to load assembly. Skip it.
117+
}
118+
}
119+
120+
var versionList = assemblies.Select(a => $"-{a.GetName().Name} - {GetVersion(a)}").OrderBy(value => value);
121+
122+
Log.Logger.ForContext("PackageVersions", string.Join("\n", versionList)).Information("Package versions ({ApplicationContext})", AppName);
123+
}
86124
}
87125
}

src/Web/WebStatus/WebStatus.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
<None Remove="Views\**" />
1212
</ItemGroup>
1313
<ItemGroup>
14-
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="2.2.8" />
14+
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="2.2.19" />
1515
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.2" />
16-
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.0" />
16+
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.2" />
1717
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" />
1818
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
1919
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.2" />
@@ -24,7 +24,7 @@
2424
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0" />
2525
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="1.0.172" />
2626
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
27-
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.2" />
27+
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
2828
<PackageReference Include="Serilog.Settings.Configuration" Version="3.0.1" />
2929
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
3030
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />

src/Web/WebStatus/appsettings.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"HealthChecks-UI": {
2+
"HealthChecks-UI-commented-out": {
33
"HealthChecks": [
44
{
55
"Name": "Ordering HTTP Check",
@@ -70,14 +70,6 @@
7070
"Uri": "http://localhost:5121/hc"
7171
}
7272
],
73-
"Webhooks": [
74-
{
75-
"Name": "",
76-
"Uri": "",
77-
"Payload": "",
78-
"RestoredPayload": ""
79-
}
80-
],
8173
"EvaluationTimeOnSeconds": 10,
8274
"MinimumSecondsBetweenFailureNotifications": 60
8375
},

0 commit comments

Comments
 (0)