MiniCron.Core 1.3.0

dotnet add package MiniCron.Core --version 1.3.0
                    
NuGet\Install-Package MiniCron.Core -Version 1.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MiniCron.Core" Version="1.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MiniCron.Core" Version="1.3.0" />
                    
Directory.Packages.props
<PackageReference Include="MiniCron.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MiniCron.Core --version 1.3.0
                    
#r "nuget: MiniCron.Core, 1.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MiniCron.Core@1.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MiniCron.Core&version=1.3.0
                    
Install as a Cake Addin
#tool nuget:?package=MiniCron.Core&version=1.3.0
                    
Install as a Cake Tool

MiniCron.Core

CI coverage Publish

Release Release

NuGet NuGet downloads dotnet

Open issues Contributors License Last commit

MiniCron.Core is a lightweight and simple library for scheduling background tasks in .NET applications using Cron expressions. It integrates seamlessly with the Microsoft.Extensions.DependencyInjection framework.

Features

  • Simple & Lightweight: Minimal setup required.
  • Dependency Injection: Access your services directly within your scheduled jobs.
  • Async Support: Fully supports asynchronous tasks.
  • Cancellation Support: Handles cancellation tokens gracefully.

Installation

Install the package via NuGet:

dotnet add package MiniCron.Core

Usage

1. Register MiniCron

In your Program.cs (or Startup.cs), register MiniCron services and define your jobs:

using MiniCron.Core.Extensions;

var builder = WebApplication.CreateBuilder(args);

// Register MiniCron
builder.Services.AddMiniCron(options =>
{
    // Run every minute
    options.AddJob("* * * * *", async (serviceProvider, cancellationToken) =>
    {
        Console.WriteLine($"Job executed at {DateTime.Now}");
        await Task.CompletedTask;
    });

    // Run every 5 minutes
    options.AddJob("*/5 * * * *", async (serviceProvider, cancellationToken) =>
    {
        // Resolve services from the DI container
        var logger = serviceProvider.GetRequiredService<ILogger<Program>>();
        logger.LogInformation("5-minute job executed.");
        
        await Task.Delay(100, cancellationToken);
    });
});

var app = builder.Build();
app.Run();

2. Using Scoped Services

Since the background service runs as a Singleton, you should create a scope to resolve Scoped services (like EF Core DbContexts):

builder.Services.AddMiniCron(options =>
{
    options.AddJob("0 12 * * *", async (serviceProvider, cancellationToken) =>
    {
        using var scope = serviceProvider.CreateScope();
        var myScopedService = scope.ServiceProvider.GetRequiredService<IMyScopedService>();
        
        await myScopedService.DoWorkAsync(cancellationToken);
    });
});

Cron Expressions

MiniCron supports standard cron expressions with 5 fields:

* * * * *
| | | | |
| | | | +----- Day of Week (0 - 6) (Sunday=0)
| | | +------- Month (1 - 12)
| | +--------- Day of Month (1 - 31)
| +----------- Hour (0 - 23)
+------------- Minute (0 - 59)

Examples:

  • * * * * *: Every minute
  • */5 * * * *: Every 5 minutes
  • 0 0 * * *: Every day at midnight
  • 0 12 * * 1: Every Monday at 12:00 PM

Documentation

Comprehensive guides and examples are available to help you integrate MiniCron.Core into your projects:

Examples

  • Console Application Example - Learn how to integrate MiniCron.Core into a minimal .NET Console application with step-by-step instructions and working examples.
  • Web Application Example - Complete guide for ASP.NET Core applications including Minimal API, MVC, Web API, and Blazor Server examples with Entity Framework Core integration.

Guides

  • Configuration Guide - Comprehensive information about configuring MiniCron.Core, including configuration sources, environment-specific settings, and a complete cron expression reference.
  • Advanced Scenarios Guide - Advanced usage patterns including error handling strategies, working with third-party services, distributed systems considerations, and performance optimization.

Quick Start

Console Application:

dotnet new console -n MyApp
cd MyApp
dotnet add package MiniCron.Core
dotnet add package Microsoft.Extensions.Hosting

See the Console Application Example for complete code.

Web Application:

dotnet new web -n MyWebApp
cd MyWebApp
dotnet add package MiniCron.Core

See the Web Application Example for complete code.

Contributing

Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❤️ by jeanlrnt

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.3.0 125 1/3/2026
1.2.0 147 12/26/2025
1.1.0 200 12/24/2025
1.0.1 287 12/17/2025
1.0.0 287 12/17/2025