██╗ ██╗███████╗███████╗████████╗██████╗ ██╗ ██╗███╗ ██╗
██║ ██╔╝██╔════╝██╔════╝╚══██╔══╝██╔══██╗██║ ██║████╗ ██║
█████╔╝ █████╗ ███████╗ ██║ ██████╔╝██║ ██║██╔██╗ ██║
██╔═██╗ ██╔══╝ ╚════██║ ██║ ██╔██╗ ██║ ██║██║╚██╗██║
██║ ██╗███████╗███████║ ██║ ██║ ██╗ ╚██████╔╝██║ ╚████║
╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
Kestrun — PowerShell brains. Kestrel speed.
Kestrun is a hybrid web framework that combines the speed and scalability of ASP.NET Core (Kestrel) with the flexibility and scripting power of PowerShell. It enables you to build web APIs, automation endpoints, and dynamic services using both C# and PowerShell in a single, integrated environment.
Full documentation and tutorial for Kestrun is available online at docs.kestrun.dev. You can find guides, API references, and usage examples to help you get started and explore advanced features.
-
🚀 Fast, cross-platform web server Powered by ASP.NET Core (Kestrel) with full access to advanced HTTP/2, header compression, and TLS options.
-
🐚 Native PowerShell integration Routes can be backed by PowerShell scripts with isolated, pooled runspaces and dynamic
$Context.Request/$Context.Responsevariables. -
🧠 Multi-language script routing Register HTTP routes using:
-
🐚 PowerShell For Building:
-
.NET 8 SDK AND .NET 9 SDK (solution multi-targets net8.0 + net9.0)
-
PowerShell 7.4+ (7.4 / 7.5 run on .NET 8; 7.6 preview runs on .NET 9)
-
Invoke-Build and Pester PowerShell modules:
Install-PSResource -Name 'InvokeBuild','Pester' -Scope CurrentUser
For Runtime (Run Only):
If you're only running Kestrun apps (not building from source), install the ASP.NET Core Runtime matching the PowerShell version you are using:
PowerShell Version Install (Run-only) Rationale 7.4 / 7.5 .NET 8 ASP.NET Core Runtime Bundles Microsoft.NETCore.App + Microsoft.AspNetCore.App 8.x 7.6 (preview) .NET 9 ASP.NET Core Runtime Preview runtime aligning with PS 7.6 build Installing the .NET SDK already gives you the corresponding runtimes. For run-only scenarios the ASP.NET Core Runtime alone is sufficient (it includes the base .NET runtime).
Download PowerShell from the official PowerShell Releases.
# List SDKs (expect 8.x and 9.x if building from source) dotnet --list-sdks # List runtimes (look for Microsoft.NETCore.App and Microsoft.AspNetCore.App) dotnet --list-runtimes | Where-Object { $_ -match 'Microsoft.(AspNetCore|NETCore).App' }
Expected (abbreviated):
Microsoft.NETCore.App 8.0.x Microsoft.AspNetCore.App 8.0.x Microsoft.NETCore.App 9.0.x Microsoft.AspNetCore.App 9.0.xIf something is missing, install the matching ASP.NET Core Runtime from the download links above.
Clone the repository:
git clone https://github.com/Kestrun/Kestrun.git cd Kestrun
-
-
🛠️ CI/CD ready
- Build- and run-time configurable
- Works in containerized / headless environments
- Supports Dev/Prod fallback module path detection
-
🛡️ Optional Add-ons Add via fluent extensions:
AddAntiforgery()middlewareAddStaticFiles(),AddDefaultFiles(),AddFileServer()AddCors(policy)orAddCorsAllowAll()AddSignalR<T>()for real-time hubsAddAuthentication()with multiple schemes (Windows, Basic, JWT, Certificate, etc.)- Ready for Swagger, gRPC, custom middleware hooks
-
⚡ Task Scheduling & Background Jobs
- Cron-based scheduling: Full cron expression support via Cronos
- Multi-language job support: Schedule PowerShell, C#, and VB.NET scripts as background jobs
- Job management: Start, stop, and monitor scheduled tasks with detailed logging
This section summarizes extension capabilities (see earlier sections for build & run instructions).
Import the module (from source):
Import-Module ./src/PowerShell/Kestrun/Kestrun.psm1The project includes an Invoke-Build script that automatically handles both C# (xUnit) and PowerShell (Pester) tests:
Invoke-Build TestInvoke-Build Kestrun.TestsInvoke-Build Test-PesterKestrun docs are built with Just-the-Docs.
All new documentation must be compatible (front matter, parent, nav_order, etc.).
See docs/ for structure.
src/CSharp/— C# core libraries and web serverKestrun/Authentication— authentication handlers and schemesKestrun/Certificates— certificate management utilitiesKestrun/Hosting— host configuration and extensionsKestrun/Languages— multi-language scripting support (C#, VB.NET, etc.)Kestrun/Logging— Serilog integration and logging helpersKestrun/Middleware— custom middleware componentsKestrun/Models— request/response classes and data modelsKestrun/Razor— Razor Pages integration with PowerShellKestrun/Scheduling— task scheduling and background job supportKestrun/Scripting— script execution and validationKestrun/Security— security utilities and helpersKestrun/SharedState— thread-safe global state managementKestrun/Utilities— shared utility functions
src/PowerShell/— PowerShell module and scriptsexamples/— Example projects and demonstrationsCSharp/Authentication— authentication examplesCSharp/Certificates— certificate usage examplesCSharp/HtmlTemplate— HTML templating examplesCSharp/MultiRoutes— multi-route examplesCSharp/RazorSample— Razor Pages examplesCSharp/Scheduling— task scheduling examplesCSharp/SharedState— shared state examplesPowerShell/— PowerShell examplesFiles/— test files and resources
tests/— Test projects (C#, PowerShell)docs/— Documentation files (Just-the-Docs)Utility/— Build and maintenance scripts.github/— GitHub Actions workflowsLint/— Code analysis rules
Contributions of all sizes are welcome — from docs improvements to new feature modules. See CONTRIBUTING.md and the online guide at https://docs.kestrun.dev/contributing.
Licensed under the MIT License. See LICENSE.
- Just-the-Docs for documentation
- ReportGenerator for code coverage reporting
- codefactor for code quality analysis
- coveralls for code coverage tracking
- GitHub for version control and collaboration
- NuGet for package management
- PowerShell Gallery for PowerShell modules
- PowerShell for scripting and automation
- .NET for the underlying framework
- Pester for PowerShell testing
- PoShLog — inspiration and portions of code for logging (MIT License)
- powershell-yaml — adapted tests and implementation code for YAML serialization (Apache-2.0 License)