diff --git a/.github/workflows/createrelease.yml b/.github/workflows/createrelease.yml index a5d5c1f2..039e7f1a 100644 --- a/.github/workflows/createrelease.yml +++ b/.github/workflows/createrelease.yml @@ -45,7 +45,11 @@ jobs: - name: Publish UI if: ${{ github.event.release.prerelease == false }} - run: dotnet publish "EstateManagementUI.BlazorServer\EstateManagementUI.BlazorServer.csproj" --configuration Release --output publishOutput -r win-x64 --self-contained + run: dotnet publish "EstateManagementUI.BlazorServer\EstateManagementUI.BlazorServer.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/EstateManagementUI.BlazorServer/EstateManagementUI.BlazorServer.csproj b/EstateManagementUI.BlazorServer/EstateManagementUI.BlazorServer.csproj index 89eda9ab..cd088ff2 100644 --- a/EstateManagementUI.BlazorServer/EstateManagementUI.BlazorServer.csproj +++ b/EstateManagementUI.BlazorServer/EstateManagementUI.BlazorServer.csproj @@ -21,6 +21,7 @@ + diff --git a/EstateManagementUI.BlazorServer/Program.cs b/EstateManagementUI.BlazorServer/Program.cs index a16ee538..d49f0d52 100644 --- a/EstateManagementUI.BlazorServer/Program.cs +++ b/EstateManagementUI.BlazorServer/Program.cs @@ -1,11 +1,54 @@ using EstateManagementUI.BlazorServer.Common; using EstateManagementUI.BlazorServer.Components; -using System.IdentityModel.Tokens.Jwt; -using Microsoft.AspNetCore.Diagnostics.HealthChecks; using HealthChecks.UI.Client; +using Microsoft.AspNetCore.Diagnostics.HealthChecks; +using Sentry.Extensibility; +using Shared.General; +using Spectre.Console; +using System.IdentityModel.Tokens.Jwt; +using System.Reflection; WebApplicationBuilder builder = WebApplication.CreateBuilder(args).LoadConfiguration().ConfigureKestrel(); + +//builder.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 = ConfigurationReader.GetValueOrDefault("SentryConfiguration", "Dsn", "N/A"); +if (sentrySection != "N/A") +{ + // Replace the condition below if you intended to only enable Sentry in certain environments. + if (builder.Environment.IsDevelopment() == false) + { + builder.WebHost.UseSentry(o => + { + o.Dsn = sentrySection; + o.SendDefaultPii = true; + o.MaxRequestBodySize = RequestSize.Always; + o.CaptureBlockingCalls = true; + o.Release = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "unknown"; + }); + } +} + // Clear default claims mapping JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();