Skip to content

Commit eac400e

Browse files
committed
Updated library to run in Cofoundry 0.2/net core.
1 parent 51184f9 commit eac400e

25 files changed

+172
-846
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Cofoundry does not include a background task runner by default so it is recommen
2525

2626
## Settings
2727

28-
- **Cofoundry.Plugins.Hangfire.DisableHangfire:** Prevents the HangFire server being configuted and started. Defaults to false.
28+
- **Cofoundry.Plugins.Hangfire.Disabled:** Prevents the HangFire server being configuted and started. Defaults to false.
2929
- **Cofoundry.Plugins.Hangfire.EnableHangfireDashboard:** Enables the HangFire dashboard for Cofoundry admin users at */admin/hangfire*. Defaults to false.
3030

3131
## Customizing the HangFire Initialization Process

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
version: '{build}'
2-
image: Visual Studio 2015
2+
image: Visual Studio 2017
33
environment:
44
NUGET_API_KEY:
55
secure: KBgtBksw79Z4kFehSqUePYoknzeWB8Tq8eAzSFPxDysRJCjJT3iUiCzk7OweTp0K

build.cake

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#tool "nuget:?package=GitVersion.CommandLine"
22

3+
using System.Text.RegularExpressions;
4+
35
//////////////////////////////////////////////////////////////////////
46
// ARGUMENTS
57
//////////////////////////////////////////////////////////////////////
@@ -10,6 +12,11 @@ var pushPackages = Argument("PushPackages", "false") == "true";
1012
bool isPrerelease = false;
1113
GitVersion versionInfo = null;
1214

15+
var projectsToBuild = new string[]{
16+
"./src/Cofoundry.Plugins.BackgroundTasks.Hangfire/Cofoundry.Plugins.BackgroundTasks.Hangfire.csproj",
17+
};
18+
19+
1320
//////////////////////////////////////////////////////////////////////
1421
// PREPARATION
1522
//////////////////////////////////////////////////////////////////////
@@ -29,12 +36,6 @@ Task("Clean")
2936
CleanDirectories("./src/**/obj/" + configuration);
3037
});
3138

32-
Task("Restore-NuGet-Packages")
33-
.IsDependentOn("Clean")
34-
.Does(() =>
35-
{
36-
NuGetRestore("./src/Cofoundry.Plugins.BackgroundTasks.Hangfire.sln");
37-
});
3839

3940
Task("Patch-Assembly-Version")
4041
.IsDependentOn("Clean")
@@ -44,49 +45,65 @@ Task("Patch-Assembly-Version")
4445
UpdateAssemblyInfo = false
4546
});
4647

47-
Information("Building version {0} of Cofoundry.Plugins.DependencyInjection.Autofac.", versionInfo.InformationalVersion);
48+
Information("Building version {0} of Cofoundry.", versionInfo.InformationalVersion);
4849

4950
isPrerelease = !string.IsNullOrEmpty(versionInfo.PreReleaseNumber);
5051

51-
var file = "./src/SolutionInfo.cs";
52-
CreateAssemblyInfo(file, new AssemblyInfoSettings {
53-
Version = versionInfo.AssemblySemVer,
54-
FileVersion = versionInfo.MajorMinorPatch + ".0",
55-
InformationalVersion = versionInfo.InformationalVersion,
56-
Copyright = "Copyright © Cofoundry.org " + DateTime.Now.Year
57-
});
52+
// Patch the version number so it's picked up when dependent projects are references
53+
// as nuget dependencies. Can't find a better way to do this.
54+
// Also this needs to run before DotNetCoreRestore for some reason (cached?)
55+
var file = MakeAbsolute(File("./src/Directory.Build.props"));
56+
var xml = System.IO.File.ReadAllText(file.FullPath, Encoding.UTF8);
57+
xml = Regex.Replace(xml, @"(<Version>)(.+)(<\/Version>)", "${1}" + versionInfo.NuGetVersion +"${3}");
58+
System.IO.File.WriteAllText(file.FullPath, xml, Encoding.UTF8);
59+
});
60+
61+
Task("Restore-NuGet-Packages")
62+
.IsDependentOn("Patch-Assembly-Version")
63+
.Does(() =>
64+
{
65+
foreach (var projectToBuild in projectsToBuild)
66+
{
67+
DotNetCoreRestore(projectToBuild);
68+
}
5869
});
5970

6071
Task("Build")
6172
.IsDependentOn("Restore-NuGet-Packages")
62-
.IsDependentOn("Patch-Assembly-Version")
6373
.Does(() =>
6474
{
65-
if(IsRunningOnWindows())
75+
76+
var settings = new DotNetCoreBuildSettings
77+
{
78+
Configuration = configuration,
79+
ArgumentCustomization = args => args
80+
.Append("/p:NuGetVersion=" + versionInfo.NuGetVersion)
81+
.Append("/p:AssemblyVersion=" + versionInfo.AssemblySemVer)
82+
.Append("/p:FileVersion=" + versionInfo.MajorMinorPatch + ".0")
83+
.Append("/p:InformationalVersion=" + versionInfo.InformationalVersion)
84+
.Append("/p:Copyright=" + "\"Copyright © Cofoundry.org " + DateTime.Now.Year + "\"")
85+
};
86+
87+
foreach (var projectToBuild in projectsToBuild)
6688
{
67-
// Use MSBuild
68-
MSBuild("./src/Cofoundry.Plugins.BackgroundTasks.Hangfire.sln", settings => settings.SetConfiguration(configuration));
89+
DotNetCoreBuild(projectToBuild, settings);
6990
}
7091
});
7192

7293
Task("Pack")
7394
.IsDependentOn("Build")
7495
.Does(() =>
7596
{
76-
var nugetFilePaths = GetFiles("./src/Cofoundry.*/*.nuspec");
77-
78-
var nuGetPackSettings = new NuGetPackSettings
79-
{
80-
Version = versionInfo.NuGetVersion,
81-
OutputDirectory = nugetPackageDir,
82-
Verbosity = NuGetVerbosity.Detailed,
83-
ArgumentCustomization = args => args.Append("-Prop Configuration=" + configuration)
84-
};
97+
var settings = new DotNetCorePackSettings
98+
{
99+
Configuration = configuration,
100+
OutputDirectory = "./artifacts/",
101+
NoBuild = true
102+
};
85103

86-
foreach (var path in nugetFilePaths)
104+
foreach (var projectToBuild in projectsToBuild)
87105
{
88-
Information("Packing:" + path);
89-
NuGetPack(path, nuGetPackSettings);
106+
DotNetCorePack(projectToBuild, settings);
90107
}
91108
});
92109

src/Cofoundry.Plugins.BackgroundTasks.Hangfire.sln

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.25123.0
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26430.13
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cofoundry.Plugins.BackgroundTasks.Hangfire", "Cofoundry.Plugins.BackgroundTasks.Hangfire\Cofoundry.Plugins.BackgroundTasks.Hangfire.csproj", "{332E1E55-2B6B-4616-BA4D-25C1E5054266}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cofoundry.Plugins.BackgroundTasks.Hangfire", "Cofoundry.Plugins.BackgroundTasks.Hangfire\Cofoundry.Plugins.BackgroundTasks.Hangfire.csproj", "{962BB845-1E06-4775-9C29-32E11B257603}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{332E1E55-2B6B-4616-BA4D-25C1E5054266}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{332E1E55-2B6B-4616-BA4D-25C1E5054266}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{332E1E55-2B6B-4616-BA4D-25C1E5054266}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{332E1E55-2B6B-4616-BA4D-25C1E5054266}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{962BB845-1E06-4775-9C29-32E11B257603}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{962BB845-1E06-4775-9C29-32E11B257603}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{962BB845-1E06-4775-9C29-32E11B257603}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{962BB845-1E06-4775-9C29-32E11B257603}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE

src/Cofoundry.Plugins.BackgroundTasks.Hangfire/Bootstrap/HangfireBackgroundTasksDependencyRegistration.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public void Register(IContainerRegister container)
1717
.RegisterType<IHangfireBackgroundTaskInitializer, HangfireBackgroundTaskInitializer>()
1818
.RegisterType<IHangfireServerInitializer, HangfireServerInitializer>()
1919
.RegisterType<IBackgroundTaskScheduler, HangfireBackgroundTaskScheduler>()
20-
.RegisterFactory<HangfireSettings, ConfigurationSettingsFactory<HangfireSettings>>()
2120
;
2221
}
2322
}

0 commit comments

Comments
 (0)