Skip to content

Commit

Permalink
add signtool_options configuration field
Browse files Browse the repository at this point in the history
  • Loading branch information
YehudaKremer committed Apr 16, 2021
1 parent 4e74a8c commit faeb0f8
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 209 deletions.
Binary file modified lib/assets/icons/LockScreenLogo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lib/assets/icons/Square150x150Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lib/assets/icons/StoreLogo.backup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lib/assets/icons/Wide310x150Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions lib/msix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class Msix {
Manifest()..generateAppxManifest();
Makepri.generatePRI();
Makeappx.pack();
Signtool.sign();
assets.cleanTemporaryFiles();
Signtool.sign();

Log.success('Msix installer created here:');
Log.success('Msix Installer Created:');
Log.link('${config.buildFilesFolder}\\${config.appName}.msix'.replaceAll('/', r'\'));

if (config.isUsingTestCertificate) Log.printTestCertificateHelp(config.certificatePath!);
Expand Down
8 changes: 4 additions & 4 deletions lib/src/assets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Assets {
}

void createIconsFolder() {
Log.taskStarted('creating app icons folder');
Log.startingTask('creating app icons folder');

var iconsFolderPath = '${_config.buildFilesFolder}\\Images';
try {
Expand All @@ -26,7 +26,7 @@ class Assets {
}

void copyIcons() {
Log.taskStarted('copying app icons');
Log.startingTask('copying app icons');

if (_config.haveAnyIconFromUser()) {
_config.tileIconPath = _copyIconToBuildFolder(_config.tileIconPath ??
Expand All @@ -48,7 +48,7 @@ class Assets {
}

void copyVCLibsFiles() {
Log.taskStarted('copying VC libraries');
Log.startingTask('copying VC libraries');

for (var file in _vCLibsFiles) {
File(file.path).copySync('${_config.buildFilesFolder}/${basename(file.path)}');
Expand All @@ -58,7 +58,7 @@ class Assets {
}

void cleanTemporaryFiles({clearMsixFiles = false}) {
Log.taskStarted('cleaning temporary files');
Log.startingTask('cleaning temporary files');

try {
var appxManifest = File('${_config.buildFilesFolder}/AppxManifest.xml');
Expand Down
13 changes: 3 additions & 10 deletions lib/src/cli/makeappx.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,13 @@ import '../configuration.dart';

class Makeappx {
static void pack() {
Log.taskStarted('packing');
Log.startingTask('packing');
final config = injector.get<Configuration>();
var msixPath = '${config.buildFilesFolder}/${config.appName}.msix';
var makeappxPath = '${config.msixToolkitPath()}/Redist.${config.architecture}/makeappx.exe';

var result = Process.runSync(makeappxPath, [
'pack',
'/v',
'/o',
'/d',
config.buildFilesFolder,
'/p',
msixPath,
]);
var result = Process.runSync(
makeappxPath, ['pack', '/v', '/o', '/d', config.buildFilesFolder, '/p', msixPath]);

if (result.stderr.toString().length > 0) {
Log.error(result.stdout, andExit: false);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cli/makepri.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import '../configuration.dart';

class Makepri {
static void generatePRI() {
Log.taskStarted('generate PRI file');
Log.startingTask('generate PRI file');
final config = injector.get<Configuration>();

if (!config.haveAnyIconFromUser()) {
Expand Down
56 changes: 25 additions & 31 deletions lib/src/cli/signtool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,42 @@ import '../configuration.dart';

class Signtool {
static void sign() {
Log.taskStarted('signing');
Log.startingTask('signing');
final config = injector.get<Configuration>();

if (!config.certificatePath.isNull) {
var signtoolPath = '${config.msixToolkitPath()}/Redist.${config.architecture}/signtool.exe';

ProcessResult signResults;

if (extension(config.certificatePath!) == '.pfx') {
signResults = Process.runSync(signtoolPath, [
'sign',
'/fd',
'SHA256',
'/a',
'/f',
config.certificatePath!,
'/p',
config.certificatePassword!,
'/tr',
'http://timestamp.digicert.com',
if (config.debugSigning) '/debug',
'${config.buildFilesFolder}\\${config.appName}.msix',
]);
} else {
signResults = Process.runSync(signtoolPath, [
'sign',
'/fd',
'SHA256',
'/a',
'/f',
config.certificatePath!,
if (config.debugSigning) '/debug',
'${config.buildFilesFolder}\\${config.appName}.msix',
]);
}
final defaultSigntoolOptions = [
'/v',
'/fd',
'SHA256',
'/a',
'/f',
config.certificatePath!,
if (extension(config.certificatePath!) == '.pfx') '/p',
if (extension(config.certificatePath!) == '.pfx') config.certificatePassword!,
'/tr',
'http://timestamp.digicert.com',
if (config.debugSigning) '/debug'
];

ProcessResult signResults = Process.runSync(signtoolPath, [
'sign',
if (config.signtoolOptions != null)
...config.signtoolOptions!
else
...defaultSigntoolOptions,
'${config.buildFilesFolder}\\${config.appName}.msix',
]);

if (!signResults.stdout.toString().contains('Number of files successfully Signed: 1') &&
signResults.stderr.toString().length > 0) {
Log.error(signResults.stdout, andExit: false);
Log.error(signResults.stderr, andExit: false);

if (signResults.stdout.toString().contains('Error: SignerSign() failed.') &&
if (config.signtoolOptions == null &&
signResults.stdout.toString().contains('Error: SignerSign() failed.') &&
!config.publisher.isNull) {
Log.printCertificateSubjectHelp();
}
Expand Down
10 changes: 8 additions & 2 deletions lib/src/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Configuration {
String? vsGeneratedIconsFolderPath;
String? executableFileName;
String? iconsBackgroundColor;
List<String>? signtoolOptions;
bool debugSigning = false;
bool isUsingTestCertificate = false;
Iterable<String>? languages;
Expand Down Expand Up @@ -60,14 +61,19 @@ class Configuration {
tileIconPath = config?['tile_icon_path']?.toString();
vsGeneratedIconsFolderPath = config?['vs_generated_images_folder_path']?.toString();
iconsBackgroundColor = config?['icons_background_color']?.toString();
signtoolOptions = config?['signtool_options']
?.toString()
.split(' ')
.where((o) => o.trim().length > 0)
.toList();
architecture = config?['architecture']?.toString();
capabilities = config?['capabilities']?.toString();
languages = _getLanguages(config);
}

/// Validate the configuration values and set default values
void validateConfigValues() {
Log.taskStarted('validating config values');
Log.startingTask('validating config values');

if (appName.isNull) {
Log.error('App name is empty, check \'appName\' at pubspec.yaml');
Expand Down Expand Up @@ -141,7 +147,7 @@ class Configuration {

/// parse the cli arguments
void _parseCliArguments(List<String> args) {
Log.taskStarted('parsing cli arguments');
Log.startingTask('parsing cli arguments');

var parser = ArgParser()
..addOption('password', abbr: 'p')
Expand Down
2 changes: 1 addition & 1 deletion lib/src/manifest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Manifest {
Manifest() : _config = injector.get<Configuration>();

void generateAppxManifest() {
Log.taskStarted('generate appx manifest');
Log.startingTask('generate appx manifest');

var manifestContent = '''<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
Expand Down
2 changes: 1 addition & 1 deletion lib/src/utils/log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Log {
}

/// Info log on a new task
static void taskStarted(String name) {
static void startingTask(String name) {
final emptyStr = _getlastMessageemptyStringLength();
lastMessageLength = name.length;
_renderProgressBar();
Expand Down
157 changes: 0 additions & 157 deletions lib/src/utils/progress_bar.dart

This file was deleted.

0 comments on commit faeb0f8

Please sign in to comment.