1
0
mirror of https://github.com/bitwarden/server synced 2026-03-02 11:21:31 +00:00

feat: Add compiler conditional ServiceDefaults to included projects

This commit is contained in:
Stephon Brown
2025-12-10 17:02:41 -06:00
parent f570887999
commit 7597b4ea71
10 changed files with 61 additions and 19 deletions

View File

@@ -7,6 +7,7 @@
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Admin' " /> <PropertyGroup Condition=" '$(RunConfiguration)' == 'Admin' " />
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Admin-SelfHost' " /> <PropertyGroup Condition=" '$(RunConfiguration)' == 'Admin-SelfHost' " />
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\ServiceDefaults\ServiceDefaults.csproj" Condition="'$(Configuration)' == 'Debug'" />
<ProjectReference Include="..\..\util\MySqlMigrations\MySqlMigrations.csproj" /> <ProjectReference Include="..\..\util\MySqlMigrations\MySqlMigrations.csproj" />
<ProjectReference Include="..\..\util\PostgresMigrations\PostgresMigrations.csproj" /> <ProjectReference Include="..\..\util\PostgresMigrations\PostgresMigrations.csproj" />
<ProjectReference Include="..\SharedWeb\SharedWeb.csproj" /> <ProjectReference Include="..\SharedWeb\SharedWeb.csproj" />

View File

@@ -1,4 +1,7 @@
using Bit.Core.Utilities; using Bit.Core.Utilities;
#if DEBUG
using Bit.ServiceDefaults;
#endif
namespace Bit.Admin; namespace Bit.Admin;
@@ -6,7 +9,7 @@ public class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
Host var builder = Host
.CreateDefaultBuilder(args) .CreateDefaultBuilder(args)
.ConfigureCustomAppConfiguration(args) .ConfigureCustomAppConfiguration(args)
.ConfigureWebHostDefaults(webBuilder => .ConfigureWebHostDefaults(webBuilder =>
@@ -17,8 +20,12 @@ public class Program
}); });
webBuilder.UseStartup<Startup>(); webBuilder.UseStartup<Startup>();
}) })
.AddSerilogFileLogging() .AddSerilogFileLogging();
.Build()
.Run(); #if DEBUG
builder.AddServiceDefaults();
#endif
builder.Build().Run();
} }
} }

View File

@@ -17,6 +17,7 @@
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Api' " /> <PropertyGroup Condition=" '$(RunConfiguration)' == 'Api' " />
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Api-SelfHost' " /> <PropertyGroup Condition=" '$(RunConfiguration)' == 'Api-SelfHost' " />
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\ServiceDefaults\ServiceDefaults.csproj" Condition="'$(Configuration)' == 'Debug'" />
<ProjectReference Include="..\SharedWeb\SharedWeb.csproj" /> <ProjectReference Include="..\SharedWeb\SharedWeb.csproj" />
<ProjectReference Include="..\Core\Core.csproj" /> <ProjectReference Include="..\Core\Core.csproj" />
</ItemGroup> </ItemGroup>

View File

@@ -1,4 +1,7 @@
using Bit.Core.Utilities; using Bit.Core.Utilities;
#if DEBUG
using Bit.ServiceDefaults;
#endif
namespace Bit.Api; namespace Bit.Api;
@@ -6,15 +9,19 @@ public class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
Host var builder = Host
.CreateDefaultBuilder(args) .CreateDefaultBuilder(args)
.ConfigureCustomAppConfiguration(args) .ConfigureCustomAppConfiguration(args)
.ConfigureWebHostDefaults(webBuilder => .ConfigureWebHostDefaults(webBuilder =>
{ {
webBuilder.UseStartup<Startup>(); webBuilder.UseStartup<Startup>();
}) })
.AddSerilogFileLogging() .AddSerilogFileLogging();
.Build()
.Run(); #if DEBUG
builder.AddServiceDefaults();
#endif
builder.Build().Run();
} }
} }

View File

@@ -14,6 +14,7 @@
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Billing' " /> <PropertyGroup Condition=" '$(RunConfiguration)' == 'Billing' " />
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\ServiceDefaults\ServiceDefaults.csproj" Condition="'$(Configuration)' == 'Debug'" />
<ProjectReference Include="..\..\bitwarden_license\src\Commercial.Core\Commercial.Core.csproj" /> <ProjectReference Include="..\..\bitwarden_license\src\Commercial.Core\Commercial.Core.csproj" />
<ProjectReference Include="..\SharedWeb\SharedWeb.csproj" /> <ProjectReference Include="..\SharedWeb\SharedWeb.csproj" />
<ProjectReference Include="..\Core\Core.csproj" /> <ProjectReference Include="..\Core\Core.csproj" />

View File

@@ -1,4 +1,7 @@
using Bit.Core.Utilities; using Bit.Core.Utilities;
#if DEBUG
using Bit.ServiceDefaults;
#endif
namespace Bit.Billing; namespace Bit.Billing;
@@ -6,15 +9,20 @@ public class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
Host var builder = Host
.CreateDefaultBuilder(args) .CreateDefaultBuilder(args)
.UseBitwardenSdk() .UseBitwardenSdk()
.ConfigureWebHostDefaults(webBuilder => .ConfigureWebHostDefaults(webBuilder =>
{ {
webBuilder.UseStartup<Startup>(); webBuilder.UseStartup<Startup>();
}) })
.AddSerilogFileLogging() .AddSerilogFileLogging();
.Build()
.Run(); #if DEBUG
builder.AddServiceDefaults();
#endif
builder.Build().Run();
} }
} }

View File

@@ -8,6 +8,7 @@
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Identity' " /> <PropertyGroup Condition=" '$(RunConfiguration)' == 'Identity' " />
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Identity-SelfHost' " /> <PropertyGroup Condition=" '$(RunConfiguration)' == 'Identity-SelfHost' " />
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\ServiceDefaults\ServiceDefaults.csproj" Condition="'$(Configuration)' == 'Debug'" />
<ProjectReference Include="..\SharedWeb\SharedWeb.csproj" /> <ProjectReference Include="..\SharedWeb\SharedWeb.csproj" />
<ProjectReference Include="..\Core\Core.csproj" /> <ProjectReference Include="..\Core\Core.csproj" />
</ItemGroup> </ItemGroup>

View File

@@ -1,4 +1,7 @@
using Bit.Core.Utilities; using Bit.Core.Utilities;
#if DEBUG
using Bit.ServiceDefaults;
#endif
namespace Bit.Identity; namespace Bit.Identity;
@@ -6,9 +9,14 @@ public class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
CreateHostBuilder(args) var builder = CreateHostBuilder(args);
.Build()
.Run(); #if DEBUG
builder.AddServiceDefaults();
#endif
builder.Build().Run();
} }
public static IHostBuilder CreateHostBuilder(string[] args) public static IHostBuilder CreateHostBuilder(string[] args)

View File

@@ -16,6 +16,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\ServiceDefaults\ServiceDefaults.csproj" Condition="'$(Configuration)' == 'Debug'" />
<ProjectReference Include="..\Core\Core.csproj" /> <ProjectReference Include="..\Core\Core.csproj" />
<ProjectReference Include="..\SharedWeb\SharedWeb.csproj" /> <ProjectReference Include="..\SharedWeb\SharedWeb.csproj" />
</ItemGroup> </ItemGroup>

View File

@@ -1,4 +1,7 @@
using Bit.Core.Utilities; using Bit.Core.Utilities;
#if DEBUG
using Bit.ServiceDefaults;
#endif
namespace Bit.Notifications; namespace Bit.Notifications;
@@ -6,15 +9,19 @@ public class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
Host var builder = Host
.CreateDefaultBuilder(args) .CreateDefaultBuilder(args)
.ConfigureCustomAppConfiguration(args) .ConfigureCustomAppConfiguration(args)
.ConfigureWebHostDefaults(webBuilder => .ConfigureWebHostDefaults(webBuilder =>
{ {
webBuilder.UseStartup<Startup>(); webBuilder.UseStartup<Startup>();
}) })
.AddSerilogFileLogging() .AddSerilogFileLogging();
.Build()
.Run(); #if DEBUG
builder.AddServiceDefaults();
#endif
builder.Build().Run();
} }
} }