From acae59429bfa4df0841a1cbdaebcf6df46c52b20 Mon Sep 17 00:00:00 2001 From: Justin Baur <19896123+justindbaur@users.noreply.github.com> Date: Sat, 3 May 2025 14:10:28 -0400 Subject: [PATCH] Add other services --- util/Setup/Program.cs | 10 ++++++++-- util/Setup/SetupHostEnvironment.cs | 12 ++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 util/Setup/SetupHostEnvironment.cs diff --git a/util/Setup/Program.cs b/util/Setup/Program.cs index 2249774a1d..25062e6bbe 100644 --- a/util/Setup/Program.cs +++ b/util/Setup/Program.cs @@ -4,6 +4,7 @@ using Bit.Core.Settings; using Bit.Migrator; using Bit.Setup.Enums; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Bit.Setup; @@ -292,6 +293,8 @@ public class Program .AddX509ChainCustomization() // Setup is always ran for self hosted, so it's fine to hard code this to true and allow chain customization .AddSingleton(new GlobalSettings { SelfHosted = true }) + .AddLogging() + .AddSingleton(new SetupHostEnvironment()) .BuildServiceProvider() .GetRequiredService() .CreateClient(); @@ -321,9 +324,12 @@ public class Program return true; } - catch + catch (Exception ex) { - Console.WriteLine($"Unable to validate installation id. Problem contacting Bitwarden {cloudRegion.ToString()} server."); + // TODO: Remove exception message before main merge?? + Console.WriteLine( + $"Unable to validate installation id. Problem contacting Bitwarden {cloudRegion.ToString()} server.\nError: {ex.Message}" + ); return false; } } diff --git a/util/Setup/SetupHostEnvironment.cs b/util/Setup/SetupHostEnvironment.cs new file mode 100644 index 0000000000..97e088741a --- /dev/null +++ b/util/Setup/SetupHostEnvironment.cs @@ -0,0 +1,12 @@ +using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Hosting; + +namespace Bit.Setup; + +internal class SetupHostEnvironment : IHostEnvironment +{ + public string ApplicationName { get; set; } = "Setup"; + public IFileProvider ContentRootFileProvider { get; set; } = new NullFileProvider(); + public string ContentRootPath { get; set; } = string.Empty; + public string EnvironmentName { get; set; } = "Production"; +}