ChrisMavrommatis.StartupTasks 2.0.0

Suggested Alternatives

ChrisMavrommatis.StartupTasks 2.0.1

Additional Details

Version 2.0.0 had different packages across frameworks. Please use 2.0.1 and up

There is a newer version of this package available.
See the version list below for details.
dotnet add package ChrisMavrommatis.StartupTasks --version 2.0.0                
NuGet\Install-Package ChrisMavrommatis.StartupTasks -Version 2.0.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="ChrisMavrommatis.StartupTasks" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ChrisMavrommatis.StartupTasks --version 2.0.0                
#r "nuget: ChrisMavrommatis.StartupTasks, 2.0.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.
// Install ChrisMavrommatis.StartupTasks as a Cake Addin
#addin nuget:?package=ChrisMavrommatis.StartupTasks&version=2.0.0

// Install ChrisMavrommatis.StartupTasks as a Cake Tool
#tool nuget:?package=ChrisMavrommatis.StartupTasks&version=2.0.0                

StartupTasks

ChrisMavrommatis.StartupTasks is a .NET library that enables you to define and execute a set of tasks during the startup phase of your ASP.NET Core application, just before the web host begins running.

Installation

Install the package via NuGet Package Manager

Install-Package ChrisMavrommatis.StartupTasks

Or via .NET CLI:

dotnet add package ChrisMavrommatis.StartupTasks

Usage

  1. Create a startup task by inheriting from IStartupTask

    public class SampleStartupTask : IStartupTask
    {
      public async Task ExecuteAsync(CancellationToken cancellationToken = default)
      {
        // Your startup task logic here
      }
    }
    
  2. Register the task using the AddStartupTask extension method

    // Other service registrations
    
    services.AddStartupTask<SampleStartupTask>();
    
    // Other service registrations
    
  3. Use the RunStartupTasksAsync extension method in your startup class just before you call the RunAsync.

    public static async Task Main(string[] args)
    {
        /*
        ... Other Code
        */
        await app.RunStartupTasksAsync();
        await app.RunAsync();
    }
    

License

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

Product 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. 
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
2.0.2 78 11/25/2024
2.0.1 78 11/13/2024
2.0.0 85 11/13/2024 2.0.0 is deprecated.
1.0.1 253 7/23/2024