Skip to content

Commit 8535219

Browse files
committed
Merge branch 'hotfix/0.30.1'
* hotfix/0.30.1: (maint) Improve logging messages for signing scripts (#203) Improve script signing task validation
2 parents 0fc0123 + 324b657 commit 8535219

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Chocolatey.Cake.Recipe/Content/sign.cake

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ BuildParameters.Tasks.SignPowerShellScriptsTask = Task("Sign-PowerShellScripts")
6565

6666
if (powerShellSigningScript == null)
6767
{
68-
Warning("Unable to find PowerShell signing script, so unable to sign PowerShell scripts.");
68+
Warning("PowerShell signing script not found. Ensure the expected script exists at './tools/Chocolatey.Cake.Recipe*/Content/'. Signing cannot proceed without it.");
6969
return;
7070
}
7171

@@ -77,7 +77,7 @@ BuildParameters.Tasks.SignPowerShellScriptsTask = Task("Sign-PowerShellScripts")
7777

7878
if (scriptsToSign.Count == 0)
7979
{
80-
Warning("Unable to find PowerShell signing script, so unable to sign PowerShell scripts.");
80+
Warning("No PowerShell scripts were identified for signing. Verify that 'GetScriptsToSign' returns valid script paths.");
8181
return;
8282
}
8383

@@ -96,7 +96,7 @@ BuildParameters.Tasks.SignPowerShellScriptsTask = Task("Sign-PowerShellScripts")
9696
{
9797
var password = System.IO.File.ReadAllText(BuildParameters.CertificatePassword);
9898

99-
Information("Signing above scripts with {0}", BuildParameters.CertificateFilePath);
99+
Information("Signing detected PowerShell scripts using certificate at: {0}", BuildParameters.CertificateFilePath);
100100

101101
StartPowershellFile(MakeAbsolute(powerShellSigningScript), args =>
102102
{
@@ -112,20 +112,26 @@ BuildParameters.Tasks.SignPowerShellScriptsTask = Task("Sign-PowerShellScripts")
112112
var files = GetFiles(BuildParameters.Paths.Directories.SignedFiles + "/**/*") - GetFiles(BuildParameters.Paths.Directories.SignedFiles + "/**/*.zip");
113113
var destination = BuildParameters.Paths.Directories.SignedFiles.CombineWithFilePath("SignedFiles.zip");
114114

115-
if (files.Count == 0 || !FileExists(destination))
115+
if (files.Count == 0)
116116
{
117-
Information("No PowerShell scripts found, or all PowerShell scripts have already been signed.");
117+
Information("No unsigned PowerShell scripts found. All scripts may have already been signed or none matched the criteria.");
118118
return;
119119
}
120120

121121

122122
Zip(BuildParameters.Paths.Directories.SignedFiles, destination, files);
123123

124+
if (!FileExists(destination))
125+
{
126+
Information("Signed script archive was not created. Ensure there were signed scripts and the archive path is accessible.");
127+
return;
128+
}
129+
124130
BuildParameters.BuildProvider.UploadArtifact(destination);
125131
}
126132
else
127133
{
128-
Information("There are no PowerShell Scripts defined to be signed.");
134+
Information("No scripts are configured for signing. Ensure 'GetScriptsToSign' is properly set.");
129135
}
130136
});
131137

0 commit comments

Comments
 (0)