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

V110 modernise build #19

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Polly.Contrib.WaitAndRetry changelog

## vNext
## 1.1.0
- Extend tests on original jitter policy to cover range of seed values
- Modernise build
- Add SourceLink support

## 1.0.0
- Launch version
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ One way to address this is to add some randomness to the wait delay. This will c

Following [exploration by Polly community members](https://github.com/App-vNext/Polly/issues/530), we now recommend a new jitter formula characterised by very smooth and even distribution of retry intervals, a well-controlled median initial retry delay, and broadly exponential backoff.

var delay = Backoff.DecorrelatedJitterBackoffV2(medianFirstDelay: TimeSpan.FromSeconds(1), retryCount: 5);
var delay = Backoff.DecorrelatedJitterBackoffV2(medianFirstRetryDelay: TimeSpan.FromSeconds(1), retryCount: 5);

var retryPolicy = Policy
.Handle<FooException>()
Expand Down
85 changes: 22 additions & 63 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ var configuration = Argument<string>("configuration", "Release");

#Tool "xunit.runner.console"
#Tool "GitVersion.CommandLine"
#Tool "Brutal.Dev.StrongNameSigner"

//////////////////////////////////////////////////////////////////////
// EXTERNAL NUGET LIBRARIES
Expand All @@ -26,22 +25,16 @@ var configuration = Argument<string>("configuration", "Release");
///////////////////////////////////////////////////////////////////////////////

var projectName = "Polly.Contrib.WaitAndRetry";
var keyName = projectName + ".snk";

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

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

// NuGet
var nuspecFilename = projectName + ".nuspec";
var nuspecSrcFile = srcDir + File(nuspecFilename);
var nuspecDestFile = buildDir + File(nuspecFilename);
var nupkgDestDir = artifactsDir + Directory("nuget-package");
var snkFile = srcDir + File(keyName);

// Gitversion
var gitVersionPath = ToolsExePath("GitVersion.exe");
Expand All @@ -54,9 +47,6 @@ string appveyorBuildNumber;
string assemblyVersion;
string assemblySemver;

// StrongNameSigner
var strongNameSignerPath = ToolsExePath("StrongNameSigner.Console.exe");

///////////////////////////////////////////////////////////////////////////////
// INNER CLASSES
///////////////////////////////////////////////////////////////////////////////
Expand All @@ -71,10 +61,10 @@ class GitVersionConfigYaml

Setup(_ =>
{
Information("==============================");
Information("Starting the cake build script");
Information("Building: " + projectName);
Information("==============================");
Information("==============================");
Information("Starting the cake build script");
Information("Building: " + projectName);
Information("==============================");
});

Teardown(_ =>
Expand All @@ -90,7 +80,6 @@ Task("__Clean")
.Does(() =>
{
DirectoryPath[] cleanDirectories = new DirectoryPath[] {
buildDir,
testResultsDir,
nupkgDestDir,
artifactsDir
Expand All @@ -103,8 +92,7 @@ Task("__Clean")
foreach(var path in solutionPaths)
{
Information("Cleaning {0}", path);
CleanDirectories(path + "/**/bin/" + configuration);
CleanDirectories(path + "/**/obj/" + configuration);
DotNetCoreClean(path.ToString());
}
});

Expand All @@ -114,7 +102,7 @@ Task("__RestoreNugetPackages")
foreach(var solution in solutions)
{
Information("Restoring NuGet Packages for {0}", solution);
NuGetRestore(solution);
DotNetCoreRestore(solution.ToString());
}
});

Expand Down Expand Up @@ -154,7 +142,9 @@ Task("__UpdateAssemblyVersionInformation")
Information("FullSemVer -> {0}", gitVersionOutput["FullSemVer"]);
Information("AssemblySemVer -> {0}", gitVersionOutput["AssemblySemVer"]);

appveyorBuildNumber = gitVersionOutput["FullSemVer"].ToString();
appveyorBuildNumber = gitVersionOutput["BranchName"].ToString().Equals("master", StringComparison.OrdinalIgnoreCase)
? gitVersionOutput["FullSemVer"].ToString()
: gitVersionOutput["InformationalVersion"].ToString();
nugetVersion = gitVersionOutput["NuGetVersion"].ToString();
assemblyVersion = gitVersionOutput["Major"].ToString() + ".0.0.0";
assemblySemver = gitVersionOutput["AssemblySemVer"].ToString();
Expand Down Expand Up @@ -210,13 +200,14 @@ Task("__BuildSolutions")
{
Information("Building {0}", solution);

MSBuild(solution, settings =>
settings
.SetConfiguration(configuration)
.WithProperty("TreatWarningsAsErrors", "true")
.UseToolVersion(MSBuildToolVersion.VS2017)
.SetVerbosity(Verbosity.Minimal)
.SetNodeReuse(false));
var dotNetCoreBuildSettings = new DotNetCoreBuildSettings {
Configuration = configuration,
Verbosity = DotNetCoreVerbosity.Minimal,
NoRestore = true,
MSBuildSettings = new DotNetCoreMSBuildSettings { TreatAllWarningsAs = MSBuildTreatAllWarningsAs.Error }
};

DotNetCoreBuild(solution.ToString(), dotNetCoreBuildSettings);
}
});

Expand All @@ -231,50 +222,20 @@ Task("__RunTests")
}
});

Task("__CopyOutputToNugetFolder")
.Does(() =>
{
var sourceDir = srcDir + Directory(projectName) + Directory("bin") + Directory(configuration);

var destDir = buildDir + Directory("lib");

Information("Copying {0} -> {1}.", sourceDir, destDir);
CopyDirectory(sourceDir, destDir);

CopyFile(nuspecSrcFile, nuspecDestFile);
});

Task("__StronglySignAssemblies")
.Does(() =>
{
//see: https://github.com/brutaldev/StrongNameSigner
var strongNameSignerSettings = new ProcessSettings()
.WithArguments(args => args
.Append("-in")
.AppendQuoted(buildDir)
.Append("-k")
.AppendQuoted(snkFile)
.Append("-l")
.AppendQuoted("Changes"));

StartProcess(strongNameSignerPath, strongNameSignerSettings);
});

Task("__CreateSignedNugetPackage")
.Does(() =>
{
var packageName = projectName;

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

var nuGetPackSettings = new NuGetPackSettings {
Id = packageName,
Title = packageName,
Version = nugetVersion,
var dotNetCorePackSettings = new DotNetCorePackSettings {
Configuration = configuration,
NoBuild = true,
OutputDirectory = nupkgDestDir
};

NuGetPack(nuspecDestFile, nuGetPackSettings);
DotNetCorePack($@"{srcDir}\{projectName}.sln", dotNetCorePackSettings);
});

//////////////////////////////////////////////////////////////////////
Expand All @@ -289,8 +250,6 @@ Task("Build")
.IsDependentOn("__UpdateAppVeyorBuildNumber")
.IsDependentOn("__BuildSolutions")
.IsDependentOn("__RunTests")
.IsDependentOn("__CopyOutputToNugetFolder")
.IsDependentOn("__StronglySignAssemblies")
.IsDependentOn("__CreateSignedNugetPackage");

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -311,6 +270,6 @@ RunTarget(target);
//////////////////////////////////////////////////////////////////////

string ToolsExePath(string exeFileName) {
var exePath = System.IO.Directory.GetFiles(@".\Tools", exeFileName, SearchOption.AllDirectories).FirstOrDefault();
var exePath = System.IO.Directory.GetFiles(@"./tools", exeFileName, SearchOption.AllDirectories).FirstOrDefault();
return exePath;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp1.1;netcoreapp2.0;net462;net472</TargetFrameworks>
<TargetFrameworks>netcoreapp1.1;netcoreapp2.0;net461;net472</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -19,7 +19,7 @@
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net462' or '$(TargetFramework)'=='net472'">
<ItemGroup Condition="'$(TargetFramework)'=='net461' or '$(TargetFramework)'=='net472'">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

Expand Down
34 changes: 0 additions & 34 deletions src/Polly.Contrib.WaitAndRetry.nuspec

This file was deleted.

49 changes: 26 additions & 23 deletions src/Polly.Contrib.WaitAndRetry/Polly.Contrib.WaitAndRetry.csproj
Original file line number Diff line number Diff line change
@@ -1,49 +1,52 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard1.1;netstandard2.0</TargetFrameworks>
<LangVersion>8.0</LangVersion>
<AssemblyName>Polly.Contrib.WaitAndRetry</AssemblyName>
<RootNamespace>Polly.Contrib.WaitAndRetry</RootNamespace>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup>
<Version>1.0.0-bumptov100-0001</Version>
<Version>1.1.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<InformationalVersion>1.0.0.0</InformationalVersion>
<PackageVersion>1.0.0-bumptov100-0001</PackageVersion>
</PropertyGroup>

<PropertyGroup>
<FileVersion>1.1.0.0</FileVersion>
<InformationalVersion>1.1.0.0</InformationalVersion>
<PackageVersion>1.1.0</PackageVersion>
<Authors>Grant Dickinson, App vNext</Authors>
<Company>App vNext</Company>
<Copyright>Copyright (c) 2019, App vNext and contributors</Copyright>
</PropertyGroup>

<PropertyGroup>
<Copyright>Copyright (c) 2020, App vNext and contributors</Copyright>
<Description>Polly.Contrib.WaitAndRetry is an extension library for Polly containing helper methods for a variety of wait-and-retry strategies.</Description>
<DefaultLanguage>en-US</DefaultLanguage>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugType>full</DebugType>
<PropertyGroup Label="SourceLink">
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<ItemGroup Label="SourceLink">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.1' ">
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
</PropertyGroup>

<ItemGroup>
<!-- The Polly dependency is artificial right now, nothing uses it. -->
<!--<PackageReference Include="Polly" Version="7.1.0" />-->
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Label="NuspecProperties">
<NeutralLanguage>en-US</NeutralLanguage>
<AssemblyTitle>Polly.Contrib.WaitAndRetry</AssemblyTitle>
<PackageLicenseExpression>BSD-3-Clause</PackageLicenseExpression>
<PackageIconUrl>https://raw.github.com/App-vNext/Polly/master/Polly.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/Polly-Contrib/Polly.Contrib.WaitAndRetry</PackageProjectUrl>
<PackageTags>Resilience Resiliency Fault-tolerance Transient-fault-handling Retry Retry-intervals Jitter</PackageTags>
<PackageReleaseNotes>See https://github.com/Polly-Contrib/Polly.Contrib.WaitAndRetry/blob/master/CHANGELOG.md for details</PackageReleaseNotes>
</PropertyGroup>
</Project>