YehudaKremer / msix

Create Msix installer for flutter windows-build files.
https://pub.dev/packages/msix
MIT License
273 stars 64 forks source link

startup_task parameters are not passed to main() #240

Open razfazz opened 9 months ago

razfazz commented 9 months ago

I am using the following startup_task configuration inside my msix_config:

  startup_task: 
    enabled: true 
    parameters: autostart 

When I restart my PC the installed flutter app starts automatically as expected but unfortunately the args are empty. It should contain ["autostart"]

Future<void> main(List<String> args) async {
 if(args.isEmpty)
      {
        //This is always true even after PC restart
      }
}
KyMHP commented 9 months ago

I'm having the same issue. Have you been able to figure it out?

YehudaKremer commented 9 months ago

I couldn't reproduce it on my machine (win11) 😕 it works as expected.

Maybe try uninstalling once and reinstalling.

KyMHP commented 9 months ago

I've just tried writing args to a txt file on startup and it shows as [] so the parameters definitely aren't getting passed in to the app. When I run flutter pub run msix:build and check the AppXManifest.xml it shows as the following. Is that correct?

<Extensions>
    <desktop:Extension Category="windows.startupTask" Executable="flutter_app.exe" EntryPoint="Windows.FullTrustApplication" uap10:Parameters="autostart">
        <desktop:StartupTask TaskId="flutterapp" Enabled="true" DisplayName="Flutter App"/>
    </desktop:Extension>
</Extensions>
razfazz commented 8 months ago

I couldn't reproduce it on my machine (win11) 😕 it works as expected.

Maybe try uninstalling once and reinstalling.

I still was not able to pass the argument autostart. Is there any way to debug this correctly? Maybe i can lookup a registry section?

YehudaKremer commented 8 months ago

please put here the full pubspec.yaml content (delete sensitive data)

wenyue commented 7 months ago

+1, not work on Windows 10, this is my settings:

version: 1.2.5

environment:
  sdk: ">=3.0.0 <4.0.0"
  flutter: ">=3.7.0 <4.0.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  flutter:
    sdk: flutter
  ffi: ^2.0.1

  webview_canvas:
    path: plugins/webview_canvas

  # Framework Plugins
  freezed_annotation: ^2.1.0
  json_annotation: ^4.8.1
  flutter_hooks: ^0.20.1
  hooks_riverpod: ^2.0.2
  riverpod_annotation: ^2.0.0
  go_router: ^12.0.0
  hive: ^2.2.3
  hive_flutter: ^1.1.0
  protobuf: ^3.0.0
  fixnum: ^1.0.1 # Used by protobuf
  easy_localization: ^3.0.1
  easy_logger: ^0.0.2 # Used by easy_localization
  logger: ^2.0.0

  # Utils
  path: ^1.8.1
  mutex: ^3.0.1
  mime: ^1.0.4
  expressions: ^0.2.4
  version: ^3.0.0

  # Security Utils
  sentry_flutter: ^7.9.0
  crypto: ^3.0.2
  encrypt: "5.0.1" # ERROR: AES padding error.
  pointycastle: ^3.7.3
  uuid: ^3.0.0

  # Algorithm and Data Structure Utils
  tuple: ^2.0.0
  collection: ^1.16.0
  quiver: ^3.1.0

  # Platform and Device Utils
  path_provider: ^2.0.11
  package_info_plus: ^4.0.1
  device_info_plus: ^9.0.1
  screen_retriever: ^0.1.6
  window_manager: ^0.3.2
  system_tray: ^2.0.3
  file_selector: ^1.0.0
  shared_preferences: ^2.0.18
  steamworks: ^0.4.4

  # Network Utils
  http: ^1.1.0
  oauth2: ^2.0.1
  url_launcher: ^6.1.10
  email_validator: ^2.1.17

  # UI Utils
  flutter_screenutil: ^5.6.0
  flutter_portal: ^1.1.2
  flutter_custom_clippers: ^2.1.0
  screenshot: ^2.1.0

  # UI Materials
  fluent_ui: ^4.2.0
  google_fonts: ^5.1.0
  phosphor_flutter: ^2.0.0
  font_awesome_flutter: ^10.4.0
  cupertino_icons: ^1.0.5

  # UI Effects
  animate_do: ^3.0.2
  flutter_staggered_animations: ^1.1.1

  # UI Widgets
  extended_image: ^8.0.2
  rive: "0.11.15" # ERROR: Build failed.
  auto_size_text: ^3.0.0
  animated_text_kit: ^4.2.2
  flutter_staggered_grid_view: ^0.7.0
  great_list_view: ^0.2.3
  flutter_rating_bar: ^4.0.1
  percent_indicator: ^4.2.3
  settings_ui: ^2.0.2
  flutter_markdown: ^0.6.14
  markdown: ^7.0.2 # Used by flutter_markdown
  multi_split_view: ^2.4.0
  bot_toast: ^4.0.3
  tutorial_coach_mark: ^1.2.9
  loading_animation_widget: ^1.2.0+4
  data_table_2: ^2.5.0
  infinite_scroll_pagination: ^4.0.0
  confetti: ^0.7.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0
  build_runner: ^2.2.0
  freezed: ^2.1.0+1
  json_serializable: ^6.6.0
  riverpod_generator: ^2.1.4
  go_router_builder: ^2.3.1
  hive_generator: ^2.0.0
  mockito: ^5.4.0
  msix: ^3.16.4
  pubspec_version_cli: ^0.1.0

# The following section is specific to Flutter packages.
flutter:
  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section:
  assets:
    - assets/documents/
    - assets/google_fonts/
    - assets/images/
    - assets/l10n/
    - assets/l10n/md/
    - assets/licenses/
    - assets/rive/
    - assets/web_page/

msix_config:
  output_path: ./installer
  display_name: *********
  execution_alias: *********
  publisher_display_name: *********
  publisher: CN=277204D9-F6EE-4197-ABC9-983517A321AA
  identity_name: *********
  logo_path: ./assets/images/img_logo.png
  capabilities: internetClientServer,privateNetworkClientServer,removableStorage
  enable_at_startup: true
  languages: en-us, zh-cn
  startup_task:
    parameters: autostart
  app_installer:
    publish_folder_path: ./installer
    hours_between_update_checks: 2
    automatic_background_task: true
    force_update_from_any_version: true
Okizeme commented 3 months ago

I have the same issue. Same parameters as @razfazz that are visible in the package manifest, but not passed to the main function in Flutter. I'm on Windows 11 Enterprise, using msix 3.16.7.

Any update on that issue @YehudaKremer?