From 59fa14b63d52b2eaae9e8ab07e651bac7c78777e Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Tue, 3 May 2022 07:34:52 +0100 Subject: [PATCH 1/4] (#40) Update to Cake.Git 1.1.0 This is to prevent the error that is being seen on the GitHub Actions Ubuntu image, due to the bundled version of the LibGit2Sharp assembly. We can't upgrade to the latest latest version, since this doesn't work with the version of Cake that we are currently using in the Recipe. --- Chocolatey.Cake.Recipe/Content/addins.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chocolatey.Cake.Recipe/Content/addins.cake b/Chocolatey.Cake.Recipe/Content/addins.cake index 6ec6a18..36c63f9 100644 --- a/Chocolatey.Cake.Recipe/Content/addins.cake +++ b/Chocolatey.Cake.Recipe/Content/addins.cake @@ -6,7 +6,7 @@ #addin nuget:?package=Cake.Eazfuscator.Net&version=0.1.0 #addin nuget:?package=Cake.Figlet&version=1.2.0 #addin nuget:?package=Cake.FileHelpers&version=3.2.0 -#addin nuget:?package=Cake.Git&version=0.19.0 +#addin nuget:?package=Cake.Git&version=1.1.0 #addin nuget:?package=Cake.Gulp&version=0.11.0 #addin nuget:?package=Cake.Incubator&version=5.1.0 #addin nuget:?package=Cake.Issues&version=0.7.1 From 000e45c727a1b6ce3435b63ec2a3392c028f3664 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Tue, 3 May 2022 07:39:25 +0100 Subject: [PATCH 2/4] (#41) Update to GitReleaseManager 0.13.0 This will allow us to make use of the Scriban templating system that shipped with this version, so that we can get consistent release notes created based on our preferred format. --- Chocolatey.Cake.Recipe/Content/toolsettings.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chocolatey.Cake.Recipe/Content/toolsettings.cake b/Chocolatey.Cake.Recipe/Content/toolsettings.cake index fa82b9a..6e08ba3 100644 --- a/Chocolatey.Cake.Recipe/Content/toolsettings.cake +++ b/Chocolatey.Cake.Recipe/Content/toolsettings.cake @@ -33,7 +33,7 @@ public static class ToolSettings public static void SetToolPreprocessorDirectives( // This is specifically pinned to 5.0.1 as later versions break compatibility with Unix. string gitVersionTool = "#tool nuget:?package=GitVersion.CommandLine&version=5.0.1", - string gitReleaseManagerTool = "#tool nuget:?package=GitReleaseManager&version=0.11.0", + string gitReleaseManagerTool = "#tool nuget:?package=GitReleaseManager&version=0.13.0", string msbuildExtensionPackTool = "#tool nuget:?package=MSBuild.Extension.Pack&version=1.9.0", string nunitTool = "#tool nuget:?package=NUnit.ConsoleRunner&version=3.10.0", string openCoverTool = "#tool nuget:?package=OpenCover&version=4.7.922", From 76c443eb2dbdf79f0c736f87040c903625e632b5 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Tue, 3 May 2022 07:41:29 +0100 Subject: [PATCH 3/4] (#42) Allow usage of .NET Global Tool for GitVersion In the same way that we can choose between .NET Global Tool and full fat .NET Framework versions of the other tools that are used within this recipe. --- Chocolatey.Cake.Recipe/Content/build.cake | 2 +- Chocolatey.Cake.Recipe/Content/toolsettings.cake | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Chocolatey.Cake.Recipe/Content/build.cake b/Chocolatey.Cake.Recipe/Content/build.cake index 54b6d29..61b7d84 100644 --- a/Chocolatey.Cake.Recipe/Content/build.cake +++ b/Chocolatey.Cake.Recipe/Content/build.cake @@ -19,7 +19,7 @@ Setup(context => context.Log.Verbosity = Verbosity.Diagnostic; } - RequireTool(ToolSettings.GitVersionTool, () => { + RequireTool(BuildParameters.IsDotNetCoreBuild ? ToolSettings.GitVersionGlobalTool : ToolSettings.GitVersionTool, () => { BuildParameters.SetBuildVersion( BuildVersion.CalculatingSemanticVersion( context: Context, diff --git a/Chocolatey.Cake.Recipe/Content/toolsettings.cake b/Chocolatey.Cake.Recipe/Content/toolsettings.cake index 6e08ba3..9904fc3 100644 --- a/Chocolatey.Cake.Recipe/Content/toolsettings.cake +++ b/Chocolatey.Cake.Recipe/Content/toolsettings.cake @@ -29,6 +29,7 @@ public static class ToolSettings public static string ReportGeneratorGlobalTool { get; private set; } public static string GitReleaseManagerGlobalTool { get; private set; } + public static string GitVersionGlobalTool { get; private set; } public static void SetToolPreprocessorDirectives( // This is specifically pinned to 5.0.1 as later versions break compatibility with Unix. @@ -45,7 +46,8 @@ public static class ToolSettings string xunitTool = "#tool nuget:?package=xunit.runner.console&version=2.4.1", string ilMergeTool = "#tool nuget:?package=ilmerge&version=3.0.41", string reportGeneratorGlobalTool = "#tool dotnet:?package=dotnet-reportgenerator-globaltool&version=4.8.5", - string gitReleaseManagerGlobalTool = "#tool dotnet:?package=GitReleaseManager.Tool&version=0.11.0" + string gitReleaseManagerGlobalTool = "#tool dotnet:?package=GitReleaseManager.Tool&version=0.13.0", + string gitVersionGlobalTool = "#tool dotnet:?package=GitVersion.Tool&version=5.10.1" ) { GitVersionTool = gitVersionTool; @@ -62,6 +64,7 @@ public static class ToolSettings ILMergeTool = ilMergeTool; ReportGeneratorGlobalTool = reportGeneratorGlobalTool; GitReleaseManagerGlobalTool = gitReleaseManagerGlobalTool; + GitVersionGlobalTool = gitVersionGlobalTool; } public static void SetToolSettings( From 85c872e4eceeac1905d4f4cdf1f6f08927238fe5 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Tue, 3 May 2022 07:43:19 +0100 Subject: [PATCH 4/4] (#43) Allow forcing usage of .NET Global Tools Rather than solely deciding which version of the tools to use based on what type of project is being built, also allow the decision to be forced using a build parameter. This is necessary for example when running GitVersion on the GitHub Actions Ubuntu image, where the .NET Framework version doesn't work at all. --- Chocolatey.Cake.Recipe/Content/build.cake | 2 +- Chocolatey.Cake.Recipe/Content/gitreleasemanager.cake | 8 ++++---- Chocolatey.Cake.Recipe/Content/parameters.cake | 8 +++++++- Chocolatey.Cake.Recipe/Content/testing.cake | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Chocolatey.Cake.Recipe/Content/build.cake b/Chocolatey.Cake.Recipe/Content/build.cake index 61b7d84..03a6bcc 100644 --- a/Chocolatey.Cake.Recipe/Content/build.cake +++ b/Chocolatey.Cake.Recipe/Content/build.cake @@ -19,7 +19,7 @@ Setup(context => context.Log.Verbosity = Verbosity.Diagnostic; } - RequireTool(BuildParameters.IsDotNetCoreBuild ? ToolSettings.GitVersionGlobalTool : ToolSettings.GitVersionTool, () => { + RequireTool(BuildParameters.IsDotNetCoreBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitVersionGlobalTool : ToolSettings.GitVersionTool, () => { BuildParameters.SetBuildVersion( BuildVersion.CalculatingSemanticVersion( context: Context, diff --git a/Chocolatey.Cake.Recipe/Content/gitreleasemanager.cake b/Chocolatey.Cake.Recipe/Content/gitreleasemanager.cake index 0d54153..36f8024 100644 --- a/Chocolatey.Cake.Recipe/Content/gitreleasemanager.cake +++ b/Chocolatey.Cake.Recipe/Content/gitreleasemanager.cake @@ -3,7 +3,7 @@ /////////////////////////////////////////////////////////////////////////////// BuildParameters.Tasks.CreateReleaseNotesTask = Task("Create-Release-Notes") - .Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => { + .Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => { if (BuildParameters.CanUseGitReleaseManager) { var settings = new GitReleaseManagerCreateSettings @@ -33,7 +33,7 @@ BuildParameters.Tasks.ExportReleaseNotesTask = Task("Export-Release-Notes") .WithCriteria(() => !BuildParameters.IsPullRequest || BuildParameters.PrepareLocalRelease, "Is pull request, and is not preparing local release") .WithCriteria(() => BuildParameters.BranchType == BranchType.Master || BuildParameters.BranchType == BranchType.Release || BuildParameters.BranchType == BranchType.HotFix || BuildParameters.PrepareLocalRelease, "Is not a releasable branch, and is not preparing local release") .WithCriteria(() => BuildParameters.IsTagged || BuildParameters.PrepareLocalRelease, "Is not a tagged build, and is not preparing local release") - .Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => { + .Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => { if (BuildParameters.CanUseGitReleaseManager) { if (BuildParameters.ShouldDownloadMilestoneReleaseNotes) @@ -61,7 +61,7 @@ BuildParameters.Tasks.ExportReleaseNotesTask = Task("Export-Release-Notes") BuildParameters.Tasks.PublishGitHubReleaseTask = Task("Publish-GitHub-Release") .IsDependentOn("Package") .WithCriteria(() => BuildParameters.ShouldPublishGitHub) - .Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => { + .Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => { if (BuildParameters.CanUseGitReleaseManager) { // Concatenating FilePathCollections should make sure we get unique FilePaths @@ -88,7 +88,7 @@ BuildParameters.Tasks.PublishGitHubReleaseTask = Task("Publish-GitHub-Release") }); BuildParameters.Tasks.CreateDefaultLabelsTask = Task("Create-Default-Labels") - .Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => { + .Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => { if (BuildParameters.CanUseGitReleaseManager) { GitReleaseManagerLabel(BuildParameters.GitHub.Token, BuildParameters.RepositoryOwner, BuildParameters.RepositoryName); diff --git a/Chocolatey.Cake.Recipe/Content/parameters.cake b/Chocolatey.Cake.Recipe/Content/parameters.cake index 8ed87aa..48fcae3 100644 --- a/Chocolatey.Cake.Recipe/Content/parameters.cake +++ b/Chocolatey.Cake.Recipe/Content/parameters.cake @@ -104,6 +104,8 @@ public static class BuildParameters public static TransifexMode TransifexPullMode { get; private set; } public static int TransifexPullPercentage { get; private set; } + public static bool PreferDotNetGlobalToolUsage { get; private set; } + static BuildParameters() { Tasks = new BuildTasks(); @@ -199,6 +201,7 @@ public static class BuildParameters context.Information("TransifexEnabled: {0}", TransifexEnabled); context.Information("CanPullTranslations: {0}", CanPullTranslations); context.Information("CanPushTranslations: {0}", CanPushTranslations); + context.Information("PreferDotNetGlobalToolUsage: {0}", PreferDotNetGlobalToolUsage); if (TransifexEnabled) { @@ -279,7 +282,8 @@ public static class BuildParameters FilePath fullReleaseNotesFilePath = null, bool? transifexEnabled = null, TransifexMode transifexPullMode = TransifexMode.OnlyTranslated, - int transifexPullPercentage = 60 + int transifexPullPercentage = 60, + bool preferDotNetGlobalToolUsage = false ) { if (context == null) @@ -356,6 +360,8 @@ public static class BuildParameters ObfuscateAssembly = obfuscateAssembly; ProductCustomAttributes = productCustomAttributes; + PreferDotNetGlobalToolUsage = preferDotNetGlobalToolUsage; + if (nuGetSources == null) { if (context.FileExists(NugetConfig)) diff --git a/Chocolatey.Cake.Recipe/Content/testing.cake b/Chocolatey.Cake.Recipe/Content/testing.cake index ffadb7a..86fc4ff 100644 --- a/Chocolatey.Cake.Recipe/Content/testing.cake +++ b/Chocolatey.Cake.Recipe/Content/testing.cake @@ -285,7 +285,7 @@ private void ReportCoverageMetric( BuildParameters.Tasks.GenerateLocalCoverageReportTask = Task("Generate-LocalCoverageReport") .WithCriteria(() => BuildParameters.Configuration != "ReleaseOfficial", "Skipping since build configuration is ReleaseOfficial") .WithCriteria(() => BuildParameters.IsLocalBuild, "Skipping due to not running a local build") - .Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild ? ToolSettings.ReportGeneratorGlobalTool : ToolSettings.ReportGeneratorTool, () => { + .Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.ReportGeneratorGlobalTool : ToolSettings.ReportGeneratorTool, () => { var coverageFiles = GetFiles(BuildParameters.Paths.Directories.TestCoverage + "/coverlet/*.xml"); if (FileExists(BuildParameters.Paths.Files.TestCoverageOutputFilePath)) {