mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Progress reporting for code signing
This commit is contained in:
@@ -23,7 +23,7 @@ public class WindowsPackCommandRunner : PackageBuilder<WindowsPackOptions>
|
||||
.Select(x => x.FullName)
|
||||
.ToArray();
|
||||
|
||||
SignFilesImpl(Options, packDir, filesToSign);
|
||||
SignFilesImpl(Options, packDir, progress, filesToSign);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -111,13 +111,13 @@ public class WindowsPackCommandRunner : PackageBuilder<WindowsPackOptions>
|
||||
} else {
|
||||
Log.Warn("Unable to set Setup.exe icon (only supported on windows)");
|
||||
}
|
||||
progress(30);
|
||||
progress(25);
|
||||
Log.Info($"Creating Setup bundle");
|
||||
SetupBundle.CreatePackageBundle(targetSetupExe, releasePkg);
|
||||
progress(70);
|
||||
progress(50);
|
||||
Log.Info("Signing Setup bundle");
|
||||
var targetDir = Path.GetDirectoryName(targetSetupExe);
|
||||
SignFilesImpl(Options, targetDir, targetSetupExe);
|
||||
SignFilesImpl(Options, targetDir, Utility.CreateProgressDelegate(progress, 50, 100), targetSetupExe);
|
||||
Log.Debug($"Setup bundle created '{Path.GetFileName(targetSetupExe)}'.");
|
||||
progress(100);
|
||||
return Task.CompletedTask;
|
||||
@@ -168,7 +168,7 @@ public class WindowsPackCommandRunner : PackageBuilder<WindowsPackOptions>
|
||||
}
|
||||
}
|
||||
|
||||
private void SignFilesImpl(WindowsSigningOptions options, string rootDir, params string[] filePaths)
|
||||
private void SignFilesImpl(WindowsSigningOptions options, string rootDir, Action<int> progress, params string[] filePaths)
|
||||
{
|
||||
var signParams = options.SignParameters;
|
||||
var signTemplate = options.SignTemplate;
|
||||
@@ -182,8 +182,10 @@ public class WindowsPackCommandRunner : PackageBuilder<WindowsPackOptions>
|
||||
|
||||
if (!string.IsNullOrEmpty(signTemplate)) {
|
||||
Log.Info($"Preparing to sign {filePaths.Length} files with custom signing template");
|
||||
foreach (var f in filePaths) {
|
||||
for (var i = 0; i < filePaths.Length; i++) {
|
||||
var f = filePaths[i];
|
||||
helper.SignPEFileWithTemplate(f, signTemplate);
|
||||
progress((int) ((double) i / filePaths.Length * 100));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -193,7 +195,7 @@ public class WindowsPackCommandRunner : PackageBuilder<WindowsPackOptions>
|
||||
|
||||
if (!string.IsNullOrEmpty(signParams)) {
|
||||
Log.Info($"Preparing to sign {filePaths.Length} files with embedded signtool.exe with parallelism of {signParallel}");
|
||||
helper.SignPEFilesWithSignTool(rootDir, filePaths, signParams, signParallel);
|
||||
helper.SignPEFilesWithSignTool(rootDir, filePaths, signParams, signParallel, progress);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public class HelperExe : HelperFile
|
||||
}
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
public void SignPEFilesWithSignTool(string rootDir, string[] filePaths, string signArguments, int parallelism)
|
||||
public void SignPEFilesWithSignTool(string rootDir, string[] filePaths, string signArguments, int parallelism, Action<int> progress)
|
||||
{
|
||||
Queue<string> pendingSign = new Queue<string>();
|
||||
|
||||
@@ -86,8 +86,9 @@ public class HelperExe : HelperFile
|
||||
$"Output was:\n" + result.StdOutput);
|
||||
}
|
||||
|
||||
Log.Info($"Signed {totalToSign - pendingSign.Count}/{totalToSign} successfully.\r\n" + result.StdOutput);
|
||||
|
||||
int processed = totalToSign - pendingSign.Count;
|
||||
Log.Debug($"Signed {processed}/{totalToSign} successfully.\r\n" + result.StdOutput);
|
||||
progress((int) ((double) processed / totalToSign * 100));
|
||||
} while (pendingSign.Count > 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ public class DeltaPackageBuilder
|
||||
targetFile.Delete();
|
||||
baseLibFiles.Remove(relativePath);
|
||||
fProcessed++;
|
||||
progress(Utility.CalculateProgress((int) ((double) fProcessed / newLibFiles.Length), 0, 70));
|
||||
progress(Utility.CalculateProgress((int) ((double) fProcessed / newLibFiles.Length * 100), 0, 70));
|
||||
} catch (Exception ex) {
|
||||
_logger.Debug(ex, String.Format("Failed to create a delta for {0}", targetFile.Name));
|
||||
Utility.DeleteFileOrDirectoryHard(targetFile.FullName + ".bsdiff", throwOnFailure: false);
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace Velopack.Packaging
|
||||
if (options.TargetRuntime?.BaseRID != SupportedTargetOs)
|
||||
throw new ArgumentException($"Target runtime must be {SupportedTargetOs}.", nameof(options.TargetRuntime));
|
||||
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
Log.Info("Beginning to package release.");
|
||||
Log.Info("Releases Directory: " + options.ReleaseDir.FullName);
|
||||
|
||||
@@ -161,7 +163,7 @@ namespace Velopack.Packaging
|
||||
taskFinish.Value = 100;
|
||||
taskFinish.StopTask();
|
||||
});
|
||||
Log.Info("[bold]Done.[/]");
|
||||
Log.Info($"[bold]Done in {DateTime.UtcNow - now}.[/]");
|
||||
} catch {
|
||||
try {
|
||||
foreach (var f in filesToCopy) {
|
||||
@@ -208,7 +210,7 @@ namespace Velopack.Packaging
|
||||
|
||||
protected virtual Task CodeSign(Action<int> progress, string packDir)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected virtual Task CreatePortablePackage(Action<int> progress, string packDir, string outputPath)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Velopack.Locators;
|
||||
@@ -8,6 +9,7 @@ using Velopack.Windows;
|
||||
|
||||
namespace Velopack.Tests
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class ShortcutTests
|
||||
{
|
||||
private readonly ITestOutputHelper _output;
|
||||
|
||||
Reference in New Issue
Block a user