Skip to content

Commit 91fd28b

Browse files
committed
Update readme and include it to the NuGet package
1 parent 547c3de commit 91fd28b

File tree

3 files changed

+61
-8
lines changed

3 files changed

+61
-8
lines changed

README.md

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,65 @@
11
# Hangfire.AspNet
22

3-
[`Install-Package Hangfire.AspNet`](https://www.nuget.org/packages/Hangfire.AspNet/)
4-
5-
[![GitHub release](https://img.shields.io/github/release/HangfireIO/Hangfire.AspNet.svg?maxAge=3600)](https://github.com/HangfireIO/Hangfire.IIS/releases)
6-
[![license](https://img.shields.io/github/license/HangfireIO/Hangfire.AspNet.svg?maxAge=3600)](https://github.com/HangfireIO/Hangfire.IIS/blob/master/LICENSE)
7-
[![Build status](https://ci.appveyor.com/api/projects/status/ywkl7xx1022odi7m?svg=true)](https://ci.appveyor.com/project/odinserj/hangfire-aspnet)
3+
[![GitHub release](https://img.shields.io/github/release/HangfireIO/Hangfire.AspNet.svg)](https://github.com/HangfireIO/Hangfire.AspNet/releases)
4+
[![Build status](https://ci.appveyor.com/api/projects/status/ywkl7xx1022odi7m?svg=true)](https://ci.appveyor.com/project/hangfireio/hangfire-aspnet)
85

96
This package provides recommended way to install Hangfire to ASP.NET applications hosted in IIS with later transition to always-running mode in mind. It contains classes and methods that use `IRegisteredObject` and `IProcessHostPreloadClient` interfaces to plug in to the IIS and ASP.NET application lifecycle more tightly than regular OWIN methods available in the `Hangfire.Core` package.
107

11-
This package also includes a Powershell script to enable Always Running mode for your application that is based on Service Autostart Providers.
8+
The package also includes a Powershell script to enable Always Running mode for your application that is based on Service Autostart Providers.
9+
10+
The package aims to replace the documentation article *Making ASP.NET application always running*.
11+
12+
## Installation
13+
14+
This project is available as a NuGet Package:
15+
16+
```powershell
17+
Install-Package Hangfire.AspNet
18+
```
19+
20+
## Usage
21+
22+
The package simplifies Hangfire configuration when an application has multiple startup paths, e.g. when using the autostart providers feature to make a web application always running as [described here](https://docs.hangfire.io/en/latest/deployment-to-production/making-aspnet-app-always-running.html).
23+
24+
We define a configuration method, and point Hangfire.AspNet to it from each startup point. Hangfire.AspNet will ensure it is called only once, so we have Hangfire initialized if any startup point is triggered.
25+
26+
```csharp
27+
public class Startup
28+
{
29+
public static IEnumerable<IDisposable> GetHangfireConfiguration()
30+
{
31+
// Calling configuration as a first step
32+
GlobalConfiguration.Configuration
33+
.SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
34+
.UseSimpleAssemblyNameTypeSerializer()
35+
.UseRecommendedSerializerSettings()
36+
.UseSqlServerStorage("connection_string");
37+
38+
// And then creating background job servers, either one or multiple
39+
yield return new BackgroundJobServer();
40+
}
1241

13-
This package aims to replace the documentation article *Making ASP.NET application always running*.
42+
public void Configuration(IAppBuilder app)
43+
{
44+
// Initializing from a regular web application startup, including
45+
// the developer workflow.
46+
app.UseHangfireAspNet(GetHangfireConfiguration);
47+
app.UseHangfireDashboard();
48+
}
49+
}
50+
```
1451

15-
Documentation is pending, please see https://github.com/HangfireIO/Hangfire.Highlighter.
52+
```csharp
53+
public class ApplicationPreload : IProcessHostPreloadClient
54+
{
55+
public void Preload(string[] parameters)
56+
{
57+
// Pointing the same configuration from the Startup class,
58+
// and Hangfire.AspNet will ensure that it is called only
59+
// once.
60+
// This method will be triggered by autostart providers
61+
// feature as described in the article referenced above.
62+
HangfireAspNet.Use(Startup.GetHangfireConfiguration);
63+
}
64+
}
65+
```

nuspecs/Hangfire.AspNet.nuspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<repository type="git" url="https://github.com/HangfireIO/Hangfire.AspNet.git" commit="%commit%" />
1111
<license type="expression">MIT</license>
1212
<description>ASP.NET integration for Hangfire.</description>
13+
<readme>README.md</readme>
1314
<icon>icon.png</icon>
1415
<copyright>Copyright © 2016-2024 Hangfire OÜ</copyright>
1516
<tags>Hangfire AspNet IIS</tags>
@@ -42,6 +43,7 @@
4243
<file src="net45\Hangfire.AspNet.xml" target="lib\net45" />
4344

4445
<file src="..\nuspecs\icon.png" />
46+
<file src="README.md" />
4547
<file src="LICENSE" />
4648
</files>
4749
</package>

psake-project.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Task Test -Depends Compile -Description "Run unit and integration tests." {
88

99
Task Collect -Depends Test -Description "Copy all artifacts to the build folder." {
1010
Collect-Assembly "Hangfire.AspNet" "net45"
11+
Collect-File "README.md"
1112
Collect-File "LICENSE"
1213
}
1314

0 commit comments

Comments
 (0)