Skip to content

Commit ed8e03a

Browse files
committed
- Update Polly dependency to latest.
- Consolidate solution and modernise build. - Add SourceLink support. - Add NetStandard 2.1 target (for .NET Core3.0 consumption) - Add test runs in netcoreapp3.0; .NET Framework 4.6.1; and .NET Framework 4.7.2 - Update FluentAssertions and xUnit dependencies - Remove duplicated test cases
1 parent 00a9202 commit ed8e03a

File tree

43 files changed

+250
-520
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+250
-520
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Polly.Caching.Distributed change log
22

3+
## 3.0.1
4+
- No functional changes
5+
- Updated Polly dependency to latest, v7.1.1
6+
- Consolidated solution and fixed build
7+
- Add SourceLink support
8+
- Added NetStandard 2.1 target (for .NET Core3.0 consumption)
9+
- Added test runs in netcoreapp3.0; .NET Framework 4.6.1; and .NET Framework 4.7.2
10+
- Updated FluentAssertions and xUnit dependencies
11+
312
## 3.0.0
413
- Allow caching of `default(TResult)`
514
- Compatible with Polly >= v7

GitVersionConfig.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
next-version: 3.0.0
1+
next-version: 3.0.1

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Polly.Caching.Distributed
22

3-
This repo contains the `Microsoft.Extensions.Caching.Distributed.IDistributedCache` provider for the [Polly](https://github.com/App-vNext/Polly) [Cache policy](https://github.com/App-vNext/Polly/wiki/Cache). The current version targets .NET Standard 1.1 and .NET Standard 2.0.
3+
This repo contains the `Microsoft.Extensions.Caching.Distributed.IDistributedCache` provider for the [Polly](https://github.com/App-vNext/Polly) [Cache policy](https://github.com/App-vNext/Polly/wiki/Cache). The current version targets .NET Standard 1.1, .NET Standard 2.0 and .NET Standard 2.1.
44

55
[![NuGet version](https://badge.fury.io/nu/Polly.Caching.Distributed.svg)](https://badge.fury.io/nu/Polly.Caching.Distributed) [![Build status](https://ci.appveyor.com/api/projects/status/pgd89nfdr9u4ig8m?svg=true)](https://ci.appveyor.com/project/joelhulen/polly-caching-Distributed) [![Slack Status](http://www.pollytalk.org/badge.svg)](http://www.pollytalk.org)
66

77
## What is Polly?
88

9-
[Polly](https://github.com/App-vNext/Polly) is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, Cache aside and Fallback in a fluent and thread-safe manner. Polly targets .NET Standard 1.1 and .NET Standard 2.0.
9+
[Polly](https://github.com/App-vNext/Polly) is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, Cache aside and Fallback in a fluent and thread-safe manner.
1010

1111
Polly is a member of the [.NET Foundation](https://www.dotnetfoundation.org/about).
1212

@@ -24,24 +24,27 @@ This project, Polly.Caching.Distributed, allows you to use Polly's `CachePolicy`
2424

2525
# Supported targets
2626

27-
Polly.Caching.Distributed supports .NET Standard 1.1 and .NET Standard 2.0.
27+
Polly.Caching.Distributed >= v3.0.1 supports .NET Standard 1.1, .NET Standard 2.0 and .NET Standard 2.1.
2828

29-
## Versions and Dependencies
29+
Polly.Caching.Distributed < v3.0.1 supports .NET Standard 1.1 and .NET Standard 2.0.
3030

31-
Polly.Caching.Distributed >=v3.0 requires:
31+
## Dependency compatibility with Polly
32+
33+
Polly.Caching.Distributed >=v3.0.1 requires:
34+
35+
+ [Polly](https://nuget.org/packages/polly) >= v7.1.1.
36+
37+
Polly.Caching.Distributed v3.0.0 requires:
3238

3339
+ [Polly](https://nuget.org/packages/polly) >= v7.0.0.
34-
+ [Microsoft.Extensions.Caching.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.Caching.Abstractions/) v2.0.2 or above.
3540

3641
Polly.Caching.Distributed >=v2.0 and <v3 requires:
3742

3843
+ [Polly](https://nuget.org/packages/polly) >= v6.0.1 and <v7.
39-
+ [Microsoft.Extensions.Caching.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.Caching.Abstractions/) v2.0.2 or above.
4044

4145
Polly.Caching.IDistributedCache <v2.0 requires:
4246

4347
+ [Polly](https://nuget.org/packages/polly) v5.4.0 or above.
44-
+ [Microsoft.Extensions.Caching.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.Caching.Abstractions/) v1.1.2 or above.
4548

4649

4750
# How to use the Polly.Caching.Distributed plugin

appveyor.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
os: Visual Studio 2017
1+
image: Visual Studio 2019
22

33
# Build script
44
build_script:
@@ -9,6 +9,7 @@ test: off
99

1010
artifacts:
1111
- path: artifacts\nuget-package\*.nupkg
12+
- path: artifacts\nuget-package\*.snupkg
1213

1314
environment:
1415
# Skip dotnet package caching on build servers

build.cake

Lines changed: 60 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -11,69 +11,61 @@ var configuration = Argument<string>("configuration", "Release");
1111

1212
#Tool "xunit.runner.console"
1313
#Tool "GitVersion.CommandLine"
14-
#Tool "Brutal.Dev.StrongNameSigner"
1514

1615
//////////////////////////////////////////////////////////////////////
1716
// EXTERNAL NUGET LIBRARIES
1817
//////////////////////////////////////////////////////////////////////
1918

2019
#addin "Cake.FileHelpers"
20+
#addin nuget:?package=Cake.Yaml
21+
#addin nuget:?package=YamlDotNet&version=5.2.1
2122

2223
///////////////////////////////////////////////////////////////////////////////
2324
// GLOBAL VARIABLES
2425
///////////////////////////////////////////////////////////////////////////////
2526

2627
var projectName = "Polly.Caching.Distributed";
27-
var keyName = "Polly.snk";
2828

2929
var solutions = GetFiles("./**/*.sln");
3030
var solutionPaths = solutions.Select(solution => solution.GetDirectory());
3131

3232
var srcDir = Directory("./src");
33-
var buildDir = Directory("./build");
3433
var artifactsDir = Directory("./artifacts");
3534
var testResultsDir = artifactsDir + Directory("test-results");
3635

3736
// NuGet
38-
var nuspecExtension = ".nuspec";
39-
var nuspecFolder = "nuget-package";
40-
var nuspecSrcFile = srcDir + File(projectName + nuspecExtension);
41-
var nuspecDestFile = buildDir + File(projectName + nuspecExtension);
42-
var nupkgDestDir = artifactsDir + Directory(nuspecFolder);
43-
var snkFile = srcDir + File(keyName);
44-
45-
var projectToNugetFolderMap = new Dictionary<string, string[]>() {
46-
{ "NetStandard11", new [] {"netstandard1.1"} },
47-
{ "NetStandard20", new [] {"netstandard2.0"} },
48-
};
37+
var nupkgDestDir = artifactsDir + Directory("nuget-package");
4938

5039
// Gitversion
5140
var gitVersionPath = ToolsExePath("GitVersion.exe");
5241
Dictionary<string, object> gitVersionOutput;
42+
var gitVersionConfigFilePath = "./GitVersionConfig.yaml";
5343

5444
// Versioning
5545
string nugetVersion;
5646
string appveyorBuildNumber;
5747
string assemblyVersion;
5848
string assemblySemver;
5949

60-
// StrongNameSigner
61-
var strongNameSignerPath = ToolsExePath("StrongNameSigner.Console.exe");
62-
50+
///////////////////////////////////////////////////////////////////////////////
51+
// INNER CLASSES
52+
///////////////////////////////////////////////////////////////////////////////
53+
class GitVersionConfigYaml
54+
{
55+
public string NextVersion { get; set; }
56+
}
6357

6458
///////////////////////////////////////////////////////////////////////////////
6559
// SETUP / TEARDOWN
6660
///////////////////////////////////////////////////////////////////////////////
6761

6862
Setup(_ =>
6963
{
70-
// ASCII art via: http://patorjk.com/software/taag/?#p=display&f=Graceful&t=Polly.Caching.Distributed%0A
7164
Information("");
72-
Information(@"");
73-
Information(@" ____ __ __ __ _ _ ___ __ ___ _ _ __ __ _ ___ ____ __ ____ ____ ____ __ ____ _ _ ____ ____ ____ ");
74-
Information(@"( _ \ / \ ( ) ( ) ( \/ ) / __) / _\ / __)/ )( \( )( ( \ / __) ( \( )/ ___)(_ _)( _ \( )( _ \/ )( \(_ _)( __)( \");
75-
Information(@" ) __/( O )/ (_/\/ (_/\ ) /_( (__ / \( (__ ) __ ( )( / /( (_ \ _ ) D ( )( \___ \ )( ) / )( ) _ () \/ ( )( ) _) ) D (");
76-
Information(@"(__) \__/ \____/\____/(__/(_)\___)\_/\_/ \___)\_)(_/(__)\_)__) \___/(_)(____/(__)(____/ (__) (__\_)(__)(____/\____/ (__) (____)(____/");
65+
Information("----------------------------------------");
66+
Information("Starting the cake build script");
67+
Information("Building: " + projectName);
68+
Information("----------------------------------------");
7769
Information("");
7870
});
7971

@@ -90,7 +82,6 @@ Task("__Clean")
9082
.Does(() =>
9183
{
9284
DirectoryPath[] cleanDirectories = new DirectoryPath[] {
93-
buildDir,
9485
testResultsDir,
9586
nupkgDestDir,
9687
artifactsDir
@@ -103,8 +94,7 @@ Task("__Clean")
10394
foreach(var path in solutionPaths)
10495
{
10596
Information("Cleaning {0}", path);
106-
CleanDirectories(path + "/**/bin/" + configuration);
107-
CleanDirectories(path + "/**/obj/" + configuration);
97+
DotNetCoreClean(path.ToString());
10898
}
10999
});
110100

@@ -114,7 +104,7 @@ Task("__RestoreNugetPackages")
114104
foreach(var solution in solutions)
115105
{
116106
Information("Restoring NuGet Packages for {0}", solution);
117-
NuGetRestore(solution);
107+
DotNetCoreRestore(solution.ToString());
118108
}
119109
});
120110

@@ -124,13 +114,29 @@ Task("__UpdateAssemblyVersionInformation")
124114
var gitVersionSettings = new ProcessSettings()
125115
.SetRedirectStandardOutput(true);
126116

127-
IEnumerable<string> outputLines;
128-
StartProcess(gitVersionPath, gitVersionSettings, out outputLines);
117+
try {
118+
IEnumerable<string> outputLines;
119+
StartProcess(gitVersionPath, gitVersionSettings, out outputLines);
120+
121+
var output = string.Join("\n", outputLines);
122+
gitVersionOutput = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(output);
123+
}
124+
catch
125+
{
126+
Information("Error reading git version information. Build may be running outside of a git repo. Falling back to version specified in " + gitVersionConfigFilePath);
127+
128+
string gitVersionYamlString = System.IO.File.ReadAllText(gitVersionConfigFilePath);
129+
GitVersionConfigYaml deserialized = DeserializeYaml<GitVersionConfigYaml>(gitVersionYamlString.Replace("next-version", "NextVersion"));
130+
string gitVersionConfig = deserialized.NextVersion;
129131

130-
var output = string.Join("\n", outputLines);
131-
gitVersionOutput = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(output);
132+
gitVersionOutput = new Dictionary<string, object>{
133+
{ "NuGetVersion", gitVersionConfig + "-NotFromGitRepo" },
134+
{ "FullSemVer", gitVersionConfig },
135+
{ "AssemblySemVer", gitVersionConfig },
136+
{ "Major", gitVersionConfig.Split('.')[0] },
137+
};
132138

133-
Information("Updated GlobalAssemblyInfo");
139+
}
134140

135141
Information("");
136142
Information("Obtained raw version info for package versioning:");
@@ -159,24 +165,22 @@ Task("__UpdateDotNetStandardAssemblyVersionNumber")
159165

160166
var attributeToValueMap = new Dictionary<string, string>() {
161167
{ "AssemblyVersion", assemblyVersion },
162-
{ "AssemblyFileVersion", assemblySemver },
163-
{ "AssemblyInformationalVersion", assemblySemver },
168+
{ "FileVersion", assemblySemver },
169+
{ "InformationalVersion", assemblySemver },
170+
{ "Version", nugetVersion },
171+
{ "PackageVersion", nugetVersion },
164172
};
165173

166-
var assemblyInfosToUpdate = GetFiles("./src/**/Properties/AssemblyInfo.cs")
167-
.Select(f => f.FullPath)
168-
.Where(f => !f.Contains("Specs"));
174+
var csproj = File("./src/" + projectName + "/" + projectName + ".csproj");
169175

170176
foreach(var attributeMap in attributeToValueMap) {
171177
var attribute = attributeMap.Key;
172178
var value = attributeMap.Value;
173179

174-
foreach(var assemblyInfo in assemblyInfosToUpdate) {
175-
var replacedFiles = ReplaceRegexInFiles(assemblyInfo, attribute + "[(]\".*\"[)]", attribute + "(\"" + value +"\")");
176-
if (!replacedFiles.Any())
177-
{
178-
throw new Exception($"{attribute} attribute could not be updated in {assemblyInfo}.");
179-
}
180+
var replacedFiles = ReplaceRegexInFiles(csproj, $@"\<{attribute}\>[^\<]*\</{attribute}\>", $@"<{attribute}>{value}</{attribute}>");
181+
if (!replacedFiles.Any())
182+
{
183+
throw new Exception($"{attribute} version could not be updated in {csproj}.");
180184
}
181185
}
182186

@@ -196,13 +200,14 @@ Task("__BuildSolutions")
196200
{
197201
Information("Building {0}", solution);
198202

199-
MSBuild(solution, settings =>
200-
settings
201-
.SetConfiguration(configuration)
202-
.WithProperty("TreatWarningsAsErrors", "true")
203-
.UseToolVersion(MSBuildToolVersion.VS2017)
204-
.SetVerbosity(Verbosity.Minimal)
205-
.SetNodeReuse(false));
203+
var dotNetCoreBuildSettings = new DotNetCoreBuildSettings {
204+
Configuration = configuration,
205+
Verbosity = DotNetCoreVerbosity.Minimal,
206+
NoRestore = true,
207+
MSBuildSettings = new DotNetCoreMSBuildSettings { TreatAllWarningsAs = MSBuildTreatAllWarningsAs.Error }
208+
};
209+
210+
DotNetCoreBuild(solution.ToString(), dotNetCoreBuildSettings);
206211
}
207212
});
208213

@@ -217,54 +222,20 @@ Task("__RunTests")
217222
}
218223
});
219224

220-
Task("__CopyOutputToNugetFolder")
221-
.Does(() =>
222-
{
223-
foreach(var project in projectToNugetFolderMap.Keys) {
224-
var sourceDir = srcDir + Directory(projectName + "." + project) + Directory("bin") + Directory(configuration);
225-
226-
foreach(var targetFolder in projectToNugetFolderMap[project]) {
227-
var destDir = buildDir + Directory("lib");
228-
229-
Information("Copying {0} -> {1}.", sourceDir, destDir);
230-
CopyDirectory(sourceDir, destDir);
231-
}
232-
}
233-
234-
CopyFile(nuspecSrcFile, nuspecDestFile);
235-
});
236-
237-
Task("__StronglySignAssemblies")
238-
.Does(() =>
239-
{
240-
//see: https://github.com/brutaldev/StrongNameSigner
241-
var strongNameSignerSettings = new ProcessSettings()
242-
.WithArguments(args => args
243-
.Append("-in")
244-
.AppendQuoted(buildDir)
245-
.Append("-k")
246-
.AppendQuoted(snkFile)
247-
.Append("-l")
248-
.AppendQuoted("Changes"));
249-
250-
StartProcess(strongNameSignerPath, strongNameSignerSettings);
251-
});
252-
253225
Task("__CreateSignedNugetPackage")
254226
.Does(() =>
255227
{
256228
var packageName = projectName;
257229

258230
Information("Building {0}.{1}.nupkg", packageName, nugetVersion);
259231

260-
var nuGetPackSettings = new NuGetPackSettings {
261-
Id = packageName,
262-
Title = packageName,
263-
Version = nugetVersion,
232+
var dotNetCorePackSettings = new DotNetCorePackSettings {
233+
Configuration = configuration,
234+
NoBuild = true,
264235
OutputDirectory = nupkgDestDir
265236
};
266237

267-
NuGetPack(nuspecDestFile, nuGetPackSettings);
238+
DotNetCorePack($@"{srcDir}\{projectName}.sln", dotNetCorePackSettings);
268239
});
269240

270241
//////////////////////////////////////////////////////////////////////
@@ -279,8 +250,6 @@ Task("Build")
279250
.IsDependentOn("__UpdateAppVeyorBuildNumber")
280251
.IsDependentOn("__BuildSolutions")
281252
.IsDependentOn("__RunTests")
282-
.IsDependentOn("__CopyOutputToNugetFolder")
283-
.IsDependentOn("__StronglySignAssemblies")
284253
.IsDependentOn("__CreateSignedNugetPackage");
285254

286255
///////////////////////////////////////////////////////////////////////////////
@@ -301,6 +270,6 @@ RunTarget(target);
301270
//////////////////////////////////////////////////////////////////////
302271

303272
string ToolsExePath(string exeFileName) {
304-
var exePath = System.IO.Directory.GetFiles(@".\Tools", exeFileName, SearchOption.AllDirectories).FirstOrDefault();
273+
var exePath = System.IO.Directory.GetFiles(@"./tools", exeFileName, SearchOption.AllDirectories).FirstOrDefault();
305274
return exePath;
306275
}

src/Directory.Build.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project>
3+
<PropertyGroup>
4+
<AssemblyOriginatorKeyFile>..\Polly.snk</AssemblyOriginatorKeyFile>
5+
<SignAssembly>true</SignAssembly>
6+
</PropertyGroup>
7+
</Project>

src/GlobalAssemblyInfo.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)