New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET Core support for Hangfire #604

merged 65 commits into from Jul 7, 2016


1 participant

odinserj commented Jul 1, 2016


.NET Core support for Hangfire is here. The following projects that target .NET Standard 1.3 were added to the solution. I've tried xproj-based approach, but it is still weird and requires to change every aspect of a building pipeline. So I decided to end up with the portable projects.

.NET Core support is currently experimental, since there no unit tests that cover the .NET Standard target – not all the required dependencies are ported to .NET Core, including Moq (that requires Castle.Core, which NuGet package for .NET Core is broken currently). However, looks like it's working, at least on Windows.

A lot of dependencies are still in alpha or beta versions, so the final release will be available only when they are ready:


There are no breaking changes for Hangfire on .NET 4.5. Consider .NET Core support as an add-on. However, some members became obsolete, but they will be removed only in 2.0.0, so you can use them for a while.

  • Dashboard was abstracted from both OWIN and ASP.NET Core HTTP Abstractions.
  • All methods that explicitly or implicitly require OWIN, such as IRequestDispatcher and RequestDispatcherContext types, became obsolete.
  • DashboardOptions.AuthorizationFilters as well as IAuthorizationFilter interface are obsolete. Use IDashboardAuthorizationFilter interface and DashboardOptions.Authorization property instead.


  • CronExpressionDescriptor support was dropped, as no ILMerge available yet.
  • DisplayNameAttribute support is not available yet.
  • EntLibLogProvider, LoupeLogProvider and ElmahLogProvider were not ported (yet).


  • TransactionScope-based transactions were replaced with DbTransaction (IPersistentJobQueue was changed to support this).
  • Hangfire.SqlServer.MSMQ is not available on .NET Core.


  • IApplicationBuilder and IServiceCollection extension methods that allow to configure Hangfire with ease.
  • AspNetCoreJobActivator that integrates with ASP.NET Core dependency injection system and knows what to do with scopes.
  • AspNetCoreLogProvider that integrate Hangfire with ASP.NET Core logging subsystem.
  • And of course, Dashboard UI is fully working.

How to use

Hangfire, Hangfire.Core, Hangfire.SqlServer and Hangfire.AspNetCore packages are already available on NuGet. They contain assemblies for both full .NET and .NET Core environments. So you can install them and play with Hangfire on .NET Core.

Installation is simple, as always. All you need is only to reference the special version 1.6.0-build-02111 in your project.json file:

"dependencies": {
    "Hangfire.Core": "1.6.0-build-02111",
    "Hangfire.SqlServer": "1.6.0-build-02111",
    "Hangfire.AspNetCore": "1.6.0-build-02111"

And configure your Startup class a bit:

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Hangfire;

namespace ConsoleApplication
    public class Startup
        public void ConfigureServices(IServiceCollection services)
            services.AddHangfire(configuration => configuration
                .UseSqlServerStorage(@"server=.\sqlexpress;database=Hangfire.Test4;integrated security=sspi;"));

        public void Configure(IApplicationBuilder app)
            app.UseHangfireDashboard(); // Will be available under http://localhost:5000/hangfire

            BackgroundJob.Enqueue(() => Console.WriteLine("Hello, .NET Core!"));

Closes #591, #476, #365 and #267.

@odinserj odinserj added this to the 1.6.0 milestone Jul 1, 2016

@odinserj odinserj added the in progress label Jul 1, 2016

@odinserj odinserj changed the title from .NET Core support for Hangfire to [WIP] .NET Core support for Hangfire Jul 1, 2016

@odinserj odinserj self-assigned this Jul 1, 2016

odinserj added some commits Jul 1, 2016

Fix ServerHeartbeatFacts
With new default interval it runs for 30 seconds
Move netstandard project to the same project folder as net45
This enables more natural workflow with using the same files without
generating huge number of links.
Remove diffs with `dev` branch that don't make sense
A lot of files were changed, and I don't want to see unnecessary changes
in a PR diff.
Authorize dashboard requests if no remote ip address found in Core
ASP.NET Core-based authorization filter is working differently
Revert authorization filter implementation
There was a bug that lead to empty remote and local ip addresses on
Add deep integration with ASP.NET Core
* Added DependencyInjection integration
* Added Logging integration
* Improved configuration experience

odinserj added some commits Jul 5, 2016

Remove "imports" directive
In other project it caused transient errors during compilation.
Place System.ComponentModel under Microsoft.NETCore.Compatibility
The same dependency order in the project.json file caused a build-time
Remove conditionals for recurring jobs under .NET Core
* Recurring jobs are uncommented
* NCrontab source code is added for .NET Core
Bring the ServerName option back
Now it is fully optional and isn't required to be unique, as GUID is
automatically appended. This step was made to remove the
System.Diagnostics.Process dependency from .NET Core version.

@odinserj odinserj changed the title from [WIP] .NET Core support for Hangfire to .NET Core support for Hangfire Jul 5, 2016

@odinserj odinserj removed the in progress label Jul 5, 2016

odinserj added some commits Jul 5, 2016

Move Microsoft.NETCore.Portable.Compatibility to the top
Just to ensure all is working fine. As we know from commit
816d85c, order matters ;-)
Migrate to Hangfire.Build 0.2.2
* CI Build versions now use "1.6.0-00324" scheme, without the "build"
word to be correctly compared to -alpha and -beta releases.
* Some common psake functions were moved to Hangfire.Build.

@odinserj odinserj merged commit ef69aa6 into dev Jul 7, 2016

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed

@odinserj odinserj deleted the netcore branch Jul 7, 2016

This was referenced Jul 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment