diff --git a/.github/workflows/createrelease.yml b/.github/workflows/createrelease.yml
index 84dc9c3..be8d817 100644
--- a/.github/workflows/createrelease.yml
+++ b/.github/workflows/createrelease.yml
@@ -47,6 +47,10 @@ jobs:
- name: Publish API
if: ${{ github.event.release.prerelease == false }}
run: dotnet publish "EstateReportingAPI\EstateReportingAPI.csproj" --configuration Release --output publishOutput -r win-x64 --self-contained
+ -p:Version=${{ steps.get_version.outputs.VERSION }}
+ -p:AssemblyVersion=${{ steps.get_version.outputs.VERSION }}
+ -p:FileVersion=${{ steps.get_version.outputs.VERSION }}
+ -p:InformationalVersion=${{ steps.get_version.outputs.VERSION }}
- name: Build Release Package
run: |
diff --git a/EstateReportingAPI/EstateReportingAPI.csproj b/EstateReportingAPI/EstateReportingAPI.csproj
index 48a32f3..12a5dfb 100644
--- a/EstateReportingAPI/EstateReportingAPI.csproj
+++ b/EstateReportingAPI/EstateReportingAPI.csproj
@@ -36,6 +36,7 @@
+
diff --git a/EstateReportingAPI/Program.cs b/EstateReportingAPI/Program.cs
index a120cf7..1230176 100644
--- a/EstateReportingAPI/Program.cs
+++ b/EstateReportingAPI/Program.cs
@@ -1,9 +1,12 @@
using Lamar.Microsoft.DependencyInjection;
using NLog;
-using System.Diagnostics.CodeAnalysis;
using NLog.Extensions.Logging;
+using Sentry.Extensibility;
+using Shared.General;
using Shared.Logger;
using Shared.Middleware;
+using System.Diagnostics.CodeAnalysis;
+using System.Reflection;
namespace EstateReportingAPI;
@@ -51,6 +54,45 @@ public static IHostBuilder CreateHostBuilder(string[] args)
});
hostBuilder.ConfigureWebHostDefaults(webBuilder =>
{
+ webBuilder.ConfigureAppConfiguration((context, configBuilder) =>
+ {
+ var env = context.HostingEnvironment;
+
+ configBuilder.SetBasePath(fi.Directory.FullName)
+ .AddJsonFile("hosting.json", optional: true)
+ .AddJsonFile($"hosting.{env.EnvironmentName}.json", optional: true)
+ .AddJsonFile("/home/txnproc/config/appsettings.json", optional: true, reloadOnChange: true)
+ .AddJsonFile($"/home/txnproc/config/appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true)
+ .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
+ .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true)
+ .AddEnvironmentVariables();
+
+ // Build a snapshot of configuration so we can use it immediately (e.g. for Sentry)
+ var builtConfig = configBuilder.Build();
+
+ // Keep existing static usage (if you must), and initialise the ConfigurationReader now.
+ Startup.Configuration = builtConfig;
+ ConfigurationReader.Initialise(Startup.Configuration);
+
+ // Configure Sentry on the webBuilder using the config snapshot.
+ var sentrySection = builtConfig.GetSection("SentryConfiguration");
+ if (sentrySection.Exists())
+ {
+ // Replace the condition below if you intended to only enable Sentry in certain environments.
+ if (env.IsDevelopment() == false)
+ {
+ webBuilder.UseSentry(o =>
+ {
+ o.Dsn = builtConfig["SentryConfiguration:Dsn"];
+ o.SendDefaultPii = true;
+ o.MaxRequestBodySize = RequestSize.Always;
+ o.CaptureBlockingCalls = true;
+ o.Release = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "unknown";
+ });
+ }
+ }
+ });
+
webBuilder.UseStartup();
webBuilder.UseConfiguration(config);
webBuilder.UseKestrel();
diff --git a/EstateReportingAPI/Startup.cs b/EstateReportingAPI/Startup.cs
index d6f5b22..ac70f2a 100644
--- a/EstateReportingAPI/Startup.cs
+++ b/EstateReportingAPI/Startup.cs
@@ -22,14 +22,6 @@ public class Startup
public Startup(IWebHostEnvironment webHostEnvironment)
{
- IConfigurationBuilder builder = new ConfigurationBuilder().SetBasePath(webHostEnvironment.ContentRootPath)
- .AddJsonFile("/home/txnproc/config/appsettings.json", true, true)
- .AddJsonFile($"/home/txnproc/config/appsettings.{webHostEnvironment.EnvironmentName}.json", optional: true)
- .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
- .AddJsonFile($"appsettings.{webHostEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true)
- .AddEnvironmentVariables();
-
- Configuration = builder.Build();
WebHostEnvironment = webHostEnvironment;
}