Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/createrelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ jobs:

- name: Publish API
if: ${{ github.event.release.prerelease == false }}
run: dotnet publish "SecurityService\SecurityService.csproj" --configuration Release --output publishOutput -r win-x64 --self-contained
run: dotnet publish "SecurityService\SecurityService.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: |
Expand Down
45 changes: 43 additions & 2 deletions SecurityService/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using NLog.Extensions.Logging;
using Serilog;
using Serilog.Events;
using Serilog.Sinks.SystemConsole.Themes;
using System;
using NLog.Extensions.Logging;
using Shared.Logger;
using Shared.Middleware;
using System;
using Sentry.Extensibility;

namespace SecurityService
{
Expand All @@ -23,6 +24,7 @@ namespace SecurityService
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using NLog;
using Shared.General;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -71,6 +73,45 @@ private static void ConfigureWeb(IHostBuilder hostBuilder) {

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<Startup>();
webBuilder.ConfigureServices(services =>
{
Expand Down
1 change: 1 addition & 0 deletions SecurityService/SecurityService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="10.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="10.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.0.3" />
<PackageReference Include="Sentry.AspNetCore" Version="6.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 1 addition & 10 deletions SecurityService/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,7 @@ public class Startup
/// <param name="webHostEnvironment">The web host environment.</param>
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();

Startup.Configuration = builder.Build();
Startup.WebHostEnvironment = webHostEnvironment;
Startup.WebHostEnvironment = webHostEnvironment;
}

#endregion
Expand Down
Loading