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
1 change: 0 additions & 1 deletion .github/workflows/pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Bootstrapper Pipeline
on:
pull_request:
branches: [main]
paths-ignore:
- .github/**
- .nuget/**
Expand Down
11 changes: 8 additions & 3 deletions .nuget/Codebelt.Bootstrapper.Console/PackageReleaseNotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ Availability: .NET 9 and .NET 8
- REMOVED ILogger{TStartup} argument from the ConsoleHostedService class in the Codebelt.Bootstrapper.Console namespace

# New Features
- ADDED RunAsync (abstract method) to the ConsoleHostedService class in the Codebelt.Bootstrapper.Console namespace
- ADDED UseServices (abstract method) to the ConsoleHostedService class in the Codebelt.Bootstrapper.Console namespace
- ADDED RunAsync (abstract method) to the ConsoleStartup class in the Codebelt.Bootstrapper.Console namespace
- ADDED ConfigureConsole (virtual method) to the ConsoleStartup class in the Codebelt.Bootstrapper.Console namespace
- ADDED HostApplicationBuilderExtensions class in the Codebelt.Bootstrapper.Console namespace that consist of extension methods for the HostApplicationBuilder class: UseBootstrapperProgram and UseMinimalConsoleProgram
- ADDED IProgramFactory interface in the Codebelt.Bootstrapper.Console namespace that provides an interface for initializing services and middleware used by an application
- ADDED MinimalConsoleHostedService class in the Codebelt.Bootstrapper.Console namespace that provides a console application that is managed by its host
- ADDED MinimalConsoleProgram class in the Codebelt.Bootstrapper.Console namespace that provides the base entry point of an application optimized for console applications
- ADDED ProgramFactory class in the Codebelt.Bootstrapper.Console namespace that is the default implementation of IProgramFactory

# Improvements
- CHANGED ConsoleHostedService class in the Codebelt.Bootstrapper.Console namespace to provide a better developer experience
- CHANGED ConsoleHostedService class in the Codebelt.Bootstrapper.Console namespace to provide a significantly better developer experience

Version: 2.0.0
Availability: .NET 6.0 and .NET 8.0
Expand Down
57 changes: 55 additions & 2 deletions .nuget/Codebelt.Bootstrapper.Console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ public class Startup : ConsoleStartup

public override void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<ICorrelationToken>(new CorrelationToken());
}

public override void UseServices(IServiceProvider serviceProvider)
public override void ConfigureConsole(IServiceProvider serviceProvider)
{
var logger = serviceProvider.GetRequiredService<ILogger<Startup>>();

Expand All @@ -62,8 +63,60 @@ public class Startup : ConsoleStartup
BootstrapperLifetime.OnApplicationStoppedCallback = () => logger.LogCritical("Stopped");
}

public async override Task RunAsync(CancellationToken cancellationToken)
public async override Task RunAsync(IServiceProvider serviceProvider, CancellationToken cancellationToken)
{
var logger = serviceProvider.GetRequiredService<ILogger<Startup>>();

logger.LogInformation("Guid: {Guid}", serviceProvider.GetRequiredService<ICorrelationToken>());

for (int dots = 0; dots <= 5; ++dots)
{
if (cancellationToken.IsCancellationRequested) { return; }
System.Console.Write($"\rFire and forget {Generate.FixedString('.', dots)}");
await Task.Delay(500, cancellationToken).ConfigureAwait(false);
}

System.Console.WriteLine("\nDone and done!");
}
}

```

And the minimal equivalent example on how to use `Codebelt.Bootstrapper.Console` in C#:

```csharp

// --- Program.cs ---

public class Program : MinimalConsoleProgram
{
static Task Main(string[] args)
{
var builder = CreateHostBuilder(args);

builder.Services.AddSingleton<ICorrelationToken>(new CorrelationToken());

var host = builder.Build();

var logger = host.Services.GetRequiredService<ILogger<Program>>();
BootstrapperLifetime.OnApplicationStartedCallback = () => logger.LogWarning("Console started.");
BootstrapperLifetime.OnApplicationStoppingCallback = () =>
{
logger.LogWarning("Stopping and cleaning ..");
Thread.Sleep(TimeSpan.FromSeconds(5)); // simulate graceful shutdown
logger.LogWarning(".. done!");
};
BootstrapperLifetime.OnApplicationStoppedCallback = () => logger.LogCritical("Console stopped.");

return host.RunAsync();
}

public async override Task RunAsync(IServiceProvider serviceProvider, CancellationToken cancellationToken)
{
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();

logger.LogInformation("Guid: {Guid}", serviceProvider.GetRequiredService<ICorrelationToken>());

for (int dots = 0; dots <= 5; ++dots)
{
if (cancellationToken.IsCancellationRequested) { return; }
Expand Down
4 changes: 4 additions & 0 deletions .nuget/Codebelt.Bootstrapper.Web/PackageReleaseNotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Availability: .NET 9 and .NET 8
- CHANGED Dependencies to latest and greatest with respect to TFMs
- REMOVED Support for TFM .NET 6 (LTS)

# New Features
- ADDED MinimalWebProgram class in the Codebelt.Bootstrapper.Web namespace that is the entry point of an application optimized for web applications
- ADDED WebApplicationBuilderExtensions class in the Codebelt.Bootstrapper.Web namespace that consist of extension methods for the WebApplicationBuilder class: UseBootstrapperLifetime

Version: 2.0.0
Availability: .NET 6.0 and .NET 8.0

Expand Down
35 changes: 35 additions & 0 deletions .nuget/Codebelt.Bootstrapper.Web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,38 @@ public class Startup : WebStartup
}

```

And the minimal equivalent example on how to use `Codebelt.Bootstrapper.Web` in C#:

```csharp

// --- Program.cs ---

public class Program : MinimalWebProgram
{
static Task Main(string[] args)
{
var builder = CreateHostBuilder(args);

var app = builder.Build();

if (app.Environment.IsLocalDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseRouting();

app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello World!");
});
});

return app.RunAsync();
}
}

```
3 changes: 3 additions & 0 deletions .nuget/Codebelt.Bootstrapper.Worker/PackageReleaseNotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Availability: .NET 9 and .NET 8
- CHANGED Dependencies to latest and greatest with respect to TFMs
- REMOVED Support for TFM .NET 6 (LTS)

# New Features
- ADDED MinimalWorkerProgram class in the Codebelt.Bootstrapper.Worker namespace that is the entry point of an application optimized for worker applications

Version: 2.0.0
Availability: .NET 6.0 and .NET 8.0

Expand Down
20 changes: 20 additions & 0 deletions .nuget/Codebelt.Bootstrapper.Worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,23 @@ public class FakeHostedService : BackgroundService
}

```

And the minimal equivalent example on how to use `Codebelt.Bootstrapper.Worker` in C#:

```csharp

// --- Program.cs ---

public class Program : MinimalWorkerProgram
{
static Task Main(string[] args)
{
var builder = CreateHostBuilder(args);
builder.Services.AddHostedService<FakeHostedService>();

var host = builder.Build();
return host.RunAsync();
}
}

```
13 changes: 13 additions & 0 deletions .nuget/Codebelt.Bootstrapper/PackageReleaseNotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ Availability: .NET 9 and .NET 8
- CHANGED Dependencies to latest and greatest with respect to TFMs
- REMOVED Support for TFM .NET 6 (LTS)

# Breaking Changes
- CHANGED UseBootstrapperStartup method on the HostBuilderExtensions class in the Codebelt.Bootstrapper namespace to be generic
- CHANGED IStartupFactory interface in the Codebelt.Bootstrapper namespace to be generic and reference an instance of TStartup
- CHANGED ProgramRoot class in the Codebelt.Bootstrapper namespace to have zero members
- CHANGED StartupFactory class in the Codebelt.Bootstrapper namespace to use generic IStartupFactory<TStartup> interface

# New Features
- ADDED HostedServiceExtensions class in the Codebelt.Bootstrapper namespace that consist of extension methods for the IHostedService interface: WaitForApplicationStartedAnnouncementAsync
- ADDED HostApplicationBuilderExtensions class in the Codebelt.Bootstrapper namespace that consist of extension methods for the IHostApplicationBuilder interface: UseBootstrapperLifetime

# Improvements
- CHANGED BootstrapperLifetime in the Codebelt.Bootstrapper namespace to support adhering to ConsoleLifetimeOptions

Version: 2.0.0
Availability: .NET 6.0 and .NET 8.0

Expand Down
27 changes: 23 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,39 @@ For more details, please refer to `PackageReleaseNotes.txt` on a per assembly ba

This major release is first and foremost focused on ironing out any wrinkles that have been introduced with .NET 9 preview releases so the final release is production ready together with the official launch from Microsoft.

Highlighted features included in this release:

- Support for consistent use of `Minimal` equivalents to all Program/Startup pairs of bootstrapper application roles

### Added

- RunAsync (abstract method) to the ConsoleHostedService class in the Codebelt.Bootstrapper.Console namespace
- UseServices (abstract method) to the ConsoleHostedService class in the Codebelt.Bootstrapper.Console namespace
- RunAsync (abstract method) to the ConsoleStartup class in the Codebelt.Bootstrapper.Console namespace
- ConfigureConsole (virtual method) to the ConsoleStartup class in the Codebelt.Bootstrapper.Console namespace
- HostApplicationBuilderExtensions class in the Codebelt.Bootstrapper namespace that consist of extension methods for the IHostApplicationBuilder interface: UseBootstrapperLifetime
- HostedServiceExtensions class in the Codebelt.Bootstrapper namespace that consist of extension methods for the IHostedService interface: WaitForApplicationStartedAnnouncementAsync
- HostApplicationBuilderExtensions class in the Codebelt.Bootstrapper.Console namespace that consist of extension methods for the HostApplicationBuilder class: UseBootstrapperProgram and UseMinimalConsoleProgram
- IProgramFactory interface in the Codebelt.Bootstrapper.Console namespace that provides an interface for initializing services and middleware used by an application
- MinimalConsoleHostedService class in the Codebelt.Bootstrapper.Console namespace that provides a console application that is managed by its host
- MinimalConsoleProgram class in the Codebelt.Bootstrapper.Console namespace that provides the base entry point of an application optimized for console applications
- ProgramFactory class in the Codebelt.Bootstrapper.Console namespace that is the default implementation of IProgramFactory
- MinimalWebProgram class in the Codebelt.Bootstrapper.Web namespace that is the entry point of an application optimized for web applications
- WebApplicationBuilderExtensions class in the Codebelt.Bootstrapper.Web namespace that consist of extension methods for the WebApplicationBuilder class: UseBootstrapperLifetime
- MinimalWorkerProgram class in the Codebelt.Bootstrapper.Worker namespace that is the entry point of an application optimized for worker applications

### Changed

- Dependencies to latest and greatest with respect to TFM
- Run (abstract method) from the ConsoleStartup class located in the Codebelt.Bootstrapper.Console namespace (breaking change)
- ConsoleHostedService class in the Codebelt.Bootstrapper.Console namespace to provide a better developer experience
- ConsoleHostedService class in the Codebelt.Bootstrapper.Console namespace to provide a significantly better developer experience
- BootstrapperLifetime in the Codebelt.Bootstrapper namespace to support adhering to ConsoleLifetimeOptions
- UseBootstrapperStartup method on the HostBuilderExtensions class in the Codebelt.Bootstrapper namespace to be generic (breaking change)
- IStartupFactory interface in the Codebelt.Bootstrapper namespace to be generic and reference an instance of TStartup (breaking change)
- ProgramRoot class in the Codebelt.Bootstrapper namespace to have zero members (breaking change)
- StartupFactory class in the Codebelt.Bootstrapper namespace to use generic IStartupFactory{TStartup} interface (breaking change)

### Removed

- Support for TFM .NET 6 (LTS)
- Run (abstract method) from the ConsoleStartup class located in the Codebelt.Bootstrapper.Console namespace (breaking change)
- ILogger{TStartup} argument from the ConsoleHostedService class in the Codebelt.Bootstrapper.Console namespace (breaking change)

## [2.0.0] - 2024-09-08
Expand Down
58 changes: 58 additions & 0 deletions Codebelt.Bootstrapper.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codebelt.Bootstrapper.WebAp
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codebelt.Bootstrapper.WebMvc.App", "app\Codebelt.Bootstrapper.WebMvc.App\Codebelt.Bootstrapper.WebMvc.App.csproj", "{0E9B237F-3E3F-457B-9046-650A3BD7C002}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codebelt.Bootstrapper.MinimalConsole.App", "app\Codebelt.Bootstrapper.MinimalConsole.App\Codebelt.Bootstrapper.MinimalConsole.App.csproj", "{40402CA7-434D-4A7B-934C-F681F8145BBB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{82912B29-BD7C-4C39-8FB0-9787D0A5BB1F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "app", "app", "{28409021-5670-4008-9061-DBAAA0FC4DA6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codebelt.Bootstrapper.MinimalWeb.App", "app\Codebelt.Bootstrapper.MinimalWeb.App\Codebelt.Bootstrapper.MinimalWeb.App.csproj", "{1335F4A6-3ECB-49CC-AE79-0D82428D2AAD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codebelt.Bootstrapper.MinimalWebApi.App", "app\Codebelt.Bootstrapper.MinimalWebApi.App\Codebelt.Bootstrapper.MinimalWebApi.App.csproj", "{82DCFF20-DAEC-4B80-83E0-3808001ACA7C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codebelt.Bootstrapper.MinimalWebApp.App", "app\Codebelt.Bootstrapper.MinimalWebApp.App\Codebelt.Bootstrapper.MinimalWebApp.App.csproj", "{3C43A01F-51E7-4166-91D5-E2088E68F4E5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codebelt.Bootstrapper.MinimalWebMvc.App", "app\Codebelt.Bootstrapper.MinimalWebMvc.App\Codebelt.Bootstrapper.MinimalWebMvc.App.csproj", "{497AD6CD-1E7E-4B4D-ACE5-CDD005A14F96}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codebelt.Bootstrapper.MinimalWorker.App", "app\Codebelt.Bootstrapper.MinimalWorker.App\Codebelt.Bootstrapper.MinimalWorker.App.csproj", "{E87D127B-4CD1-4009-962E-EEF70A522C13}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -69,10 +85,52 @@ Global
{0E9B237F-3E3F-457B-9046-650A3BD7C002}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E9B237F-3E3F-457B-9046-650A3BD7C002}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E9B237F-3E3F-457B-9046-650A3BD7C002}.Release|Any CPU.Build.0 = Release|Any CPU
{40402CA7-434D-4A7B-934C-F681F8145BBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{40402CA7-434D-4A7B-934C-F681F8145BBB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40402CA7-434D-4A7B-934C-F681F8145BBB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40402CA7-434D-4A7B-934C-F681F8145BBB}.Release|Any CPU.Build.0 = Release|Any CPU
{1335F4A6-3ECB-49CC-AE79-0D82428D2AAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1335F4A6-3ECB-49CC-AE79-0D82428D2AAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1335F4A6-3ECB-49CC-AE79-0D82428D2AAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1335F4A6-3ECB-49CC-AE79-0D82428D2AAD}.Release|Any CPU.Build.0 = Release|Any CPU
{82DCFF20-DAEC-4B80-83E0-3808001ACA7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82DCFF20-DAEC-4B80-83E0-3808001ACA7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82DCFF20-DAEC-4B80-83E0-3808001ACA7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82DCFF20-DAEC-4B80-83E0-3808001ACA7C}.Release|Any CPU.Build.0 = Release|Any CPU
{3C43A01F-51E7-4166-91D5-E2088E68F4E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C43A01F-51E7-4166-91D5-E2088E68F4E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C43A01F-51E7-4166-91D5-E2088E68F4E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C43A01F-51E7-4166-91D5-E2088E68F4E5}.Release|Any CPU.Build.0 = Release|Any CPU
{497AD6CD-1E7E-4B4D-ACE5-CDD005A14F96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{497AD6CD-1E7E-4B4D-ACE5-CDD005A14F96}.Debug|Any CPU.Build.0 = Debug|Any CPU
{497AD6CD-1E7E-4B4D-ACE5-CDD005A14F96}.Release|Any CPU.ActiveCfg = Release|Any CPU
{497AD6CD-1E7E-4B4D-ACE5-CDD005A14F96}.Release|Any CPU.Build.0 = Release|Any CPU
{E87D127B-4CD1-4009-962E-EEF70A522C13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E87D127B-4CD1-4009-962E-EEF70A522C13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E87D127B-4CD1-4009-962E-EEF70A522C13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E87D127B-4CD1-4009-962E-EEF70A522C13}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B14D0DBF-E9F8-458C-B45B-54931042F167} = {82912B29-BD7C-4C39-8FB0-9787D0A5BB1F}
{6CE93B27-64D0-4D7B-BF0A-D3FBCC9E620F} = {82912B29-BD7C-4C39-8FB0-9787D0A5BB1F}
{0A40098D-3820-4290-9939-B74E610EA77F} = {82912B29-BD7C-4C39-8FB0-9787D0A5BB1F}
{7CC75DC6-CF80-4119-9B44-47A7EC9266A0} = {28409021-5670-4008-9061-DBAAA0FC4DA6}
{E90730C8-7954-449B-A592-4674FDAAE15A} = {82912B29-BD7C-4C39-8FB0-9787D0A5BB1F}
{4CC94CFF-7ECA-41D0-9682-74B51E61488D} = {28409021-5670-4008-9061-DBAAA0FC4DA6}
{FBD6FE71-9A45-4535-88A7-C91267C05276} = {28409021-5670-4008-9061-DBAAA0FC4DA6}
{5247A3BE-AF60-4BD9-AB79-952632D1184C} = {28409021-5670-4008-9061-DBAAA0FC4DA6}
{F4111595-6908-47C6-9293-EEAC1F4D3127} = {28409021-5670-4008-9061-DBAAA0FC4DA6}
{0E9B237F-3E3F-457B-9046-650A3BD7C002} = {28409021-5670-4008-9061-DBAAA0FC4DA6}
{40402CA7-434D-4A7B-934C-F681F8145BBB} = {28409021-5670-4008-9061-DBAAA0FC4DA6}
{1335F4A6-3ECB-49CC-AE79-0D82428D2AAD} = {28409021-5670-4008-9061-DBAAA0FC4DA6}
{82DCFF20-DAEC-4B80-83E0-3808001ACA7C} = {28409021-5670-4008-9061-DBAAA0FC4DA6}
{3C43A01F-51E7-4166-91D5-E2088E68F4E5} = {28409021-5670-4008-9061-DBAAA0FC4DA6}
{497AD6CD-1E7E-4B4D-ACE5-CDD005A14F96} = {28409021-5670-4008-9061-DBAAA0FC4DA6}
{E87D127B-4CD1-4009-962E-EEF70A522C13} = {28409021-5670-4008-9061-DBAAA0FC4DA6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {72FB037E-3629-4CDB-812E-D577A3D4FD26}
EndGlobalSection
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@
</ItemGroup>

<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<PackageReference Include="Codebelt.Extensions.Xunit" Version="9.0.0-preview.9" />
<PackageReference Include="Codebelt.Extensions.Xunit" Version="9.0.0-preview.10" />
</ItemGroup>
</Project>
5 changes: 3 additions & 2 deletions app/Codebelt.Bootstrapper.Console.App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ public class Program : ConsoleProgram<Startup>
static Task Main(string[] args)
{
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5)); // simulate cronjob that has exceeded a max. running time
return CreateHostBuilder(args)
.Build().RunAsync(cts.Token);
var builder = CreateHostBuilder(args);
var host = builder.Build();
return host.RunAsync(cts.Token);
}
}
}
Loading