LasseVK.Bootstrapping
0.1.2-prerelease
dotnet add package LasseVK.Bootstrapping --version 0.1.2-prerelease
NuGet\Install-Package LasseVK.Bootstrapping -Version 0.1.2-prerelease
<PackageReference Include="LasseVK.Bootstrapping" Version="0.1.2-prerelease" />
<PackageVersion Include="LasseVK.Bootstrapping" Version="0.1.2-prerelease" />
<PackageReference Include="LasseVK.Bootstrapping" />
paket add LasseVK.Bootstrapping --version 0.1.2-prerelease
#r "nuget: LasseVK.Bootstrapping, 0.1.2-prerelease"
#:package LasseVK.Bootstrapping@0.1.2-prerelease
#addin nuget:?package=LasseVK.Bootstrapping&version=0.1.2-prerelease&prerelease
#tool nuget:?package=LasseVK.Bootstrapping&version=0.1.2-prerelease&prerelease
LasseVK.Bootstrapping
This package implements a way to handle registration of services and configuration in a .NET application using the Microsoft.Extensions.Hosting package.
It allows you to place a ModuleBootstrapper class in each class library, and invoke those during program setup
to allow them to register services, without having to expose internal implementations from the libraries.
This means you can move services and configuration registration out of Program.cs and into the libraries where
the functionality and services reside.
Discord
You can reach me through my Discord server.
Nuget package
You can find the Nuget package here.
Installation
You can install the package from the command line, using dotnet:
dotnet add package LasseVK.Bootstrapping
Or you can use your favorite IDE which should have a Nuget package manager built in.
Framework support
The package supports the following .NET versions:
- .NET 8.0 (until november 10, 2026)
- .NET 9.0 (until november 10, 2026)
- .NET 10.0 (until november 14, 2028)
This follows the official supported versions policies from Microsoft:
Note: After support for a .NET version ends, the package will still exist on nuget for use with that version, but I won't guarantee that updates to that version will be made.
Usage
After installing the package in your projects, you can create a ModuleBootstrapper class in each class library, and invoke those during program setup
to allow them to register services, without having to expose internal implementations from the libraries.
This means you can move services and configuration registration out of Program.cs and into the libraries where
the functionality and services reside.
Here's an example, in a separate class library you can declare the following two types:
public interface ISomeService
{
string GetSomeValue();
}
internal class SomeService : ISomeService
{
public string GetSomeValue()
{
return "Some value";
}
}
then you also declare a ModuleBootstrapper class in the same project:
public class ModuleBootstrapper : IModuleBootstrapper
{
public static void Bootstrap(IHostApplicationBuilder builder)
{
builder.Services.AddSingleton<ISomeService, SomeService>();
}
}
I also tend to add an ApplicationBootstrapper class in my main program project that registers
everything that is specific to the program:
public class ApplicationBootstrapper : IModuleBootstrapper
{
public static void Bootstrap(IHostApplicationBuilder builder)
{
builder.Bootstrap(new TheClassLibrary.ModuleBootstrapper());
// specific registrations of services found in the main program project
}
}
Then, in program.cs, you can have the following code:
using LasseVK.Bootstrapping;
using Microsoft.Extensions.Hosting;
var builder = Host.CreateApplicationBuilder(args);
builder.Bootstrap(new ApplicationBootstrapper()); // this in turn calls the class library
var host = builder.Build();
await host.InitializeAsync();
await host.RunAsync();
For my own projects, this might be the entire Program.cs content, with all service
registrations moved to the ApplicationBootstrapper class, or into separate project
ModuleBootstrapper classes.
If anything is required to run against the host instance after building the host, but before
running the application, I try to move this into classes implementing the
IModuleInitializer interface. Again, I try to separate concerns into separate
class libraries with vertical slices of functionality.
Since calling builder.Bootstrap(new SomeModuleBootstrapper()) will only invoke the
Bootstrap method on that type once per type (ie. once for SomeModuleBootstrapper),
any class library projects that also rely on other class libraries being registered
will all call the Bootstrap method with the respective module bootstrappers
from those dependency class libraries. This ensures all services are registered, even
if the main program project itself only require a few of them.
At most, you will construct additional instances of the bootstrapper classes on program
execution, but each Bootstrap method will only be invoked once.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.8)
-
net8.0
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.8)
-
net9.0
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.2-prerelease | 53 | 5/26/2026 |
| 0.1.1-prerelease | 55 | 5/23/2026 |
| 0.1.0-prerelease | 61 | 5/22/2026 |