Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #287 and add override-executable option #288

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ See [Configurations Examples And Use Cases].
<summary>MSIX configuration (click to expand)</summary>

| YAML name | Command-line argument | Description (from Microsoft [Package manifest schema reference]) | Example |
| ----------------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------- |
| ----------------------------------- | ------------------------------- |---------------------------------------------------------------------------------------------------|---------------------------------------------|
| `display_name` | `--display-name` `-d` | A friendly app name that can be displayed to users. | `Flutter App` |
| `publisher_display_name` | `--publisher-display-name` `-u` | A friendly name for the publisher that can be displayed to users. | `Company Name` |
| `identity_name` | `--identity-name` `-i` | Defines the unique identifier for the app. | `company.suite.flutterapp` |
Expand All @@ -74,6 +74,7 @@ See [Configurations Examples And Use Cases].
| `protocol_activation` | `--protocol-activation` | [Protocols activation] that will activate the app. | `http,https` |
| `app_uri_handler_hosts` | `--app-uri-handler-hosts` | Enable [apps for websites] using app URI handlers app. | `test.com, test2.info` |
| `execution_alias` | `--execution-alias` | [Execution alias] command (cmd) that will activate the app. | `myapp` |
| `override_executable` | `--override-executable` | Overrides file name of the startup executable. | `myapp.exe` |
| `enable_at_startup` | `--enable-at-startup` | App start at startup or user log-in. | `true` |
| `store` | `--store` | Generate a MSIX file for publishing to the Microsoft Store. | `false` |
| `os_min_version` | `--os-min-version` | Set minimum OS version, default is `10.0.17763.0` | `10.0.17763.0` |
Expand Down
21 changes: 15 additions & 6 deletions lib/src/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import 'sign_tool.dart';

/// Handles loading and validating the configuration values
class Configuration {
static final List<String> _blacklistedExecutables = [
'PSFLauncher64.exe',
'crashpad_handler.exe'
];
Comment on lines +17 to +20

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case we run into this issue again after another package added another EXE. Can we use $appName.exe like this commit

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is already implemented. See overrideExecutableFileName

final List<String> _arguments;
final Logger _logger = GetIt.I<Logger>();
late ArgResults _args;
Expand All @@ -33,6 +37,7 @@ class Configuration {
String? capabilities;
String? logoPath;
String? executableFileName;
String? overrideExecutableFileName;
List<String>? signToolOptions;
List<String>? windowsBuildArgs;
late Iterable<String> protocolActivation;
Expand Down Expand Up @@ -89,6 +94,8 @@ class Configuration {
outputPath = _args['output-path'] ?? yaml['output_path'];
outputName = _args['output-name'] ?? yaml['output_name'];
executionAlias = _args['execution-alias'] ?? yaml['execution_alias'];
overrideExecutableFileName =
_args['override-executable'] ?? yaml['override_executable'];
if (_args['sign-msix'].toString() == 'false' ||
yaml['sign_msix']?.toString().toLowerCase() == 'false') {
signMsix = false;
Expand Down Expand Up @@ -365,12 +372,13 @@ class Configuration {
throw 'Build files not found at $buildFilesFolder, first run "flutter build windows" then try again';
}

executableFileName = await Directory(buildFilesFolder)
.list()
.firstWhere((file) =>
file.path.endsWith('.exe') &&
!file.path.contains('PSFLauncher64.exe'))
.then((file) => basename(file.path));
executableFileName = overrideExecutableFileName ??
await Directory(buildFilesFolder)
.list()
.firstWhere((file) =>
file.path.endsWith('.exe') &&
!_blacklistedExecutables.any((b) => file.path.contains(b)))
.then((file) => basename(file.path));
}

/// Declare and parse the cli arguments
Expand All @@ -393,6 +401,7 @@ class Configuration {
..addOption('windows-build-args')
..addOption('protocol-activation')
..addOption('execution-alias')
..addOption('override-executable')
..addOption('file-extension', abbr: 'f')
..addOption('architecture', abbr: 'h')
..addOption('capabilities', abbr: 'e')
Expand Down