Skip to content
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
merged 65 commits into from Jul 7, 2016
Merged

.NET Core support for Hangfire #604

merged 65 commits into from Jul 7, 2016

Conversation

@odinserj
Copy link
Member

odinserj commented Jul 1, 2016

image

.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:

Changes

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.

Hangfire.Core.NetStandard

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

Hangfire.SqlServer.NetStandard

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

Hangfire.AspNetCore

  • 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
            app.UseHangfireServer();

            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 .NET Core support for Hangfire [WIP] .NET Core support for Hangfire Jul 1, 2016
@odinserj odinserj self-assigned this Jul 1, 2016
odinserj added 6 commits Jul 1, 2016
With new default interval it runs for 30 seconds
This enables more natural workflow with using the same files without
generating huge number of links.
A lot of files were changed, and I don't want to see unnecessary changes
in a PR diff.
odinserj added 9 commits Jul 5, 2016
* Recurring jobs are uncommented
* NCrontab source code is added for .NET Core
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 [WIP] .NET Core support for Hangfire .NET Core support for Hangfire Jul 5, 2016
@odinserj odinserj removed the in progress label Jul 5, 2016
odinserj added 9 commits Jul 5, 2016
Just to ensure all is working fine. As we know from commit
816d85c, order matters ;-)
* 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
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@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
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.