From 6a0e8635428ed093aab5dcf6e38bf4b47039d6d0 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 16 May 2024 01:50:51 -0700 Subject: [PATCH] (#152) Only run signing steps on Windows All of the signing steps in Chocolatey.Cake.Recipe require one of two things. Either: - usage of Windows PowerShell - usage of signtool.exe (with a hard coded path in Windows) Neither of these things are found on a Linux/Mac build runner. As such we need to add criteria to only run tasks on Windows. This criteria wasn't "needed" previously, since there was another criteria present to only run when on TeamCity, or the signing certificate was in place. When the new verify task, which doesn't have this same criteria, was added, it started failing the build, as the other tasks weren't being explicit about this requirement. This commit addresses this underlying problem, by adding an explicit criteria to each step related to signing to ensure running on Windows so that it isn't forgotten about in the future. --- Chocolatey.Cake.Recipe/Content/sign.cake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Chocolatey.Cake.Recipe/Content/sign.cake b/Chocolatey.Cake.Recipe/Content/sign.cake index bd88ebc..be3b412 100644 --- a/Chocolatey.Cake.Recipe/Content/sign.cake +++ b/Chocolatey.Cake.Recipe/Content/sign.cake @@ -14,6 +14,7 @@ // limitations under the License. BuildParameters.Tasks.VerifyPowerShellScriptsTask = Task("Verify-PowerShellScripts") + .WithCriteria(() => BuildParameters.BuildAgentOperatingSystem == PlatformFamily.Windows, "Skipping due to not running on Windows") .WithCriteria(() => BuildParameters.ShouldVerifyPowerShellScripts, "Skipping since verifying PowerShell scripts has been disabled") .Does(() => { @@ -45,6 +46,7 @@ BuildParameters.Tasks.VerifyPowerShellScriptsTask = Task("Verify-PowerShellScrip }); BuildParameters.Tasks.SignPowerShellScriptsTask = Task("Sign-PowerShellScripts") + .WithCriteria(() => BuildParameters.BuildAgentOperatingSystem == PlatformFamily.Windows, "Skipping due to not running on Windows") .WithCriteria(() => (!string.IsNullOrWhiteSpace(BuildParameters.CertificateFilePath) && FileExists(BuildParameters.CertificateFilePath)) || BuildSystem.IsRunningOnTeamCity, "Skipping because unable to find certificate, and not running on TeamCity") .WithCriteria(() => BuildParameters.ShouldAuthenticodeSignPowerShellScripts, "Skipping since authenticode signing of PowerShell scripts has been disabled") .Does(() => @@ -105,6 +107,7 @@ BuildParameters.Tasks.SignPowerShellScriptsTask = Task("Sign-PowerShellScripts") }); BuildParameters.Tasks.SignAssembliesTask = Task("Sign-Assemblies") + .WithCriteria(() => BuildParameters.BuildAgentOperatingSystem == PlatformFamily.Windows, "Skipping due to not running on Windows") .WithCriteria(() => (!string.IsNullOrWhiteSpace(BuildParameters.CertificateFilePath) && FileExists(BuildParameters.CertificateFilePath)) || BuildSystem.IsRunningOnTeamCity, "Skipping because unable to find certificate, and not running on TeamCity") .WithCriteria(() => BuildParameters.ShouldAuthenticodeSignOutputAssemblies, "Skipping since authenticode signing of output assemblies has been disabled") .Does(() => @@ -153,6 +156,7 @@ BuildParameters.Tasks.SignAssembliesTask = Task("Sign-Assemblies") }); BuildParameters.Tasks.SignMsisTask = Task("Sign-Msis") + .WithCriteria(() => BuildParameters.BuildAgentOperatingSystem == PlatformFamily.Windows, "Skipping due to not running on Windows") .WithCriteria(() => (!string.IsNullOrWhiteSpace(BuildParameters.CertificateFilePath) && FileExists(BuildParameters.CertificateFilePath)) || BuildSystem.IsRunningOnTeamCity, "Skipping because unable to find certificate, and not running on TeamCity") .WithCriteria(() => BuildParameters.ShouldAuthenticodeSignMsis, "Skipping since authenticode signing of msi's has been disabled") .Does(() =>