diff --git a/build.cake b/build.cake index 7d73ccf..2037618 100644 --- a/build.cake +++ b/build.cake @@ -52,6 +52,12 @@ var projectToNugetFolderMap = new Dictionary() { var gitVersionPath = ToolsExePath("GitVersion.exe"); Dictionary gitVersionOutput; +// Versioning +string nugetVersion; +string appveyorBuildNumber; +string assemblyVersion; +string assemblySemver; + // StrongNameSigner var strongNameSignerPath = ToolsExePath("StrongNameSigner.Console.exe"); @@ -125,37 +131,62 @@ Task("__UpdateAssemblyVersionInformation") gitVersionOutput = new JsonParser().Parse>(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 NetStandard AssemblyVersions to {0}", assemblySemVer); + Information("Updating Assembly Version Information"); + + var attributeToValueMap = new Dictionary() { + { "AssemblyVersion", assemblyVersion }, + { "AssemblyFileVersion", assemblySemver }, + { "AssemblyInformationalVersion", assemblySemver }, + }; + var assemblyInfosToUpdate = GetFiles("./src/**/Properties/AssemblyInfo.cs") .Select(f => f.FullPath) .Where(f => !f.Contains("Specs")); - foreach(var assemblyInfo in assemblyInfosToUpdate) { - var replacedFiles = ReplaceRegexInFiles(assemblyInfo, "AssemblyVersion[(]\".*\"[)]", "AssemblyVersion(\"" + assemblySemVer +"\")"); - if (!replacedFiles.Any()) - { - throw new Exception($"AssemblyVersion could not be updated in {assemblyInfo}."); + 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") @@ -186,12 +217,10 @@ Task("__RunTests") } }); - Task("__CopyOutputToNugetFolder") .Does(() => { - foreach(var project in projectToNugetFolderMap.Keys) - { + foreach(var project in projectToNugetFolderMap.Keys) { var sourceDir = srcDir + Directory(projectName + "." + project) + Directory("bin") + Directory(configuration); foreach(var targetFolder in projectToNugetFolderMap[project]) { @@ -205,10 +234,25 @@ Task("__CopyOutputToNugetFolder") 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 nugetVersion = gitVersionOutput["NuGetVersion"].ToString(); var packageName = projectName; Information("Building {0}.{1}.nupkg", packageName, nugetVersion); @@ -223,22 +267,6 @@ Task("__CreateSignedNugetPackage") NuGetPack(nuspecDestFile, nuGetPackSettings); }); -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); -}); - ////////////////////////////////////////////////////////////////////// // BUILD TASKS ////////////////////////////////////////////////////////////////////// diff --git a/src/Polly.Extensions.Http.NetStandard11/Properties/AssemblyInfo.cs b/src/Polly.Extensions.Http.NetStandard11/Properties/AssemblyInfo.cs index 7b38350..acd1709 100644 --- a/src/Polly.Extensions.Http.NetStandard11/Properties/AssemblyInfo.cs +++ b/src/Polly.Extensions.Http.NetStandard11/Properties/AssemblyInfo.cs @@ -3,7 +3,9 @@ using System.Runtime.CompilerServices; [assembly: AssemblyTitle("Polly.Extensions.Http")] -[assembly: AssemblyVersion("1.0.4.0")] +[assembly: AssemblyInformationalVersion("1.0.5.0")] +[assembly: AssemblyFileVersion("1.0.5.0")] +[assembly: AssemblyVersion("1.0.0.0")] [assembly: CLSCompliant(true)] [assembly: InternalsVisibleTo("Polly.Extensions.Http.NetStandard11.Specs")] \ No newline at end of file