Skip to content

Commit

Permalink
Adopt new versioning strategy
Browse files Browse the repository at this point in the history
Adopt new package and DLL versioning strategy,  See App-vNext#442.  Nuget packages will be full semver-numbered.  AssemblyFileVersion and AssemblyInformationVersion attributes will be full semver-numbered.  AssemblyVersion attribute will by Major.0.0.0 numbered.
  • Loading branch information
reisenberger committed May 3, 2018
1 parent 29addde commit 72df90d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 15 deletions.
64 changes: 50 additions & 14 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ var projectToNugetFolderMap = new Dictionary<string, string[]>() {
var gitVersionPath = ToolsExePath("GitVersion.exe");
Dictionary<string, object> gitVersionOutput;

// Versioning
string nugetVersion;
string appveyorBuildNumber;
string assemblyVersion;
string assemblySemver;

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

Expand Down Expand Up @@ -125,31 +131,62 @@ Task("__UpdateAssemblyVersionInformation")
gitVersionOutput = new JsonParser().Parse<Dictionary<string, object>>(output);
Information("Updated GlobalAssemblyInfo");
Information("AssemblyVersion -> {0}", gitVersionOutput["AssemblySemVer"]);
Information("AssemblyFileVersion -> {0}", gitVersionOutput["MajorMinorPatch"]);
Information("AssemblyInformationalVersion -> {0}", gitVersionOutput["InformationalVersion"]);
Information("");
Information("Obtained raw version info for package versioning:");
Information("NuGetVersion -> {0}", gitVersionOutput["NuGetVersion"]);
Information("FullSemVer -> {0}", gitVersionOutput["FullSemVer"]);
Information("AssemblySemVer -> {0}", gitVersionOutput["AssemblySemVer"]);
appveyorBuildNumber = gitVersionOutput["FullSemVer"].ToString();
nugetVersion = gitVersionOutput["NuGetVersion"].ToString();
assemblyVersion = gitVersionOutput["Major"].ToString() + ".0.0.0";
assemblySemver = gitVersionOutput["AssemblySemVer"].ToString();
Information("");
Information("Mapping versioning information to:");
Information("Appveyor build number -> {0}", appveyorBuildNumber);
Information("Nuget package version -> {0}", nugetVersion);
Information("AssemblyVersion -> {0}", assemblyVersion);
Information("AssemblyFileVersion -> {0}", assemblySemver);
Information("AssemblyInformationalVersion -> {0}", assemblySemver);
});

Task("__UpdateDotNetStandardAssemblyVersionNumber")
.Does(() =>
{
// NOTE: TEMPORARY fix only, while GitVersionTask does not support .Net Standard assemblies. See https://github.com/App-vNext/Polly/issues/176.
// This build Task can be removed when GitVersionTask supports .Net Standard assemblies.
var assemblySemVer = gitVersionOutput["AssemblySemVer"].ToString();
Information("Updating NetStandard1.1 AssemblyVersion to {0}", assemblySemVer);
var replacedFiles = ReplaceRegexInFiles("./src/Polly.NetStandard11/Properties/AssemblyInfo.cs", "AssemblyVersion[(]\".*\"[)]", "AssemblyVersion(\"" + assemblySemVer +"\")");
if (!replacedFiles.Any())
{
Information("NetStandard1.1 AssemblyVersion could not be updated.");
Information("Updating Assembly Version Information");
var attributeToValueMap = new Dictionary<string, string>() {
{ "AssemblyVersion", assemblyVersion },
{ "AssemblyFileVersion", assemblySemver },
{ "AssemblyInformationalVersion", assemblySemver },
};
var assemblyInfosToUpdate = GetFiles("./src/**/Properties/AssemblyInfo.cs")
.Select(f => f.FullPath)
.Where(f => !f.Contains("Specs"));
foreach(var attributeMap in attributeToValueMap) {
var attribute = attributeMap.Key;
var value = attributeMap.Value;
foreach(var assemblyInfo in assemblyInfosToUpdate) {
var replacedFiles = ReplaceRegexInFiles(assemblyInfo, attribute + "[(]\".*\"[)]", attribute + "(\"" + value +"\")");
if (!replacedFiles.Any())
{
throw new Exception($"{attribute} attribute could not be updated in {assemblyInfo}.");
}
}
}
});

Task("__UpdateAppVeyorBuildNumber")
.WithCriteria(() => AppVeyor.IsRunningOnAppVeyor)
.Does(() =>
{
var fullSemVer = gitVersionOutput["FullSemVer"].ToString();
AppVeyor.UpdateBuildVersion(fullSemVer);
AppVeyor.UpdateBuildVersion(appveyorBuildNumber);
});

Task("__BuildSolutions")
Expand Down Expand Up @@ -214,7 +251,6 @@ Task("__StronglySignAssemblies")
Task("__CreateSignedNugetPackage")
.Does(() =>
{
var nugetVersion = gitVersionOutput["NuGetVersion"].ToString();
var packageName = projectName;
Information("Building {0}.{1}.nupkg", packageName, nugetVersion);
Expand Down
4 changes: 3 additions & 1 deletion src/Polly.NetStandard11/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System.Runtime.CompilerServices;

[assembly: AssemblyTitle("Polly")]
[assembly: AssemblyVersion("5.9.1.0")]
[assembly: AssemblyInformationalVersion("5.9.1.0")]
[assembly: AssemblyFileVersion("5.9.1.0")]
[assembly: AssemblyVersion("5.0.0.0")]
[assembly: CLSCompliant(true)]

[assembly: InternalsVisibleTo("Polly.NetStandard11.Specs")]

0 comments on commit 72df90d

Please sign in to comment.