YehudaKremer / msix

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

[BUG] Command: powershell.exe -NoProfile -NonInteractive "new-object System.Security.Cryptography.X509Certificates.X509Certificate2 #186

Closed SebghatYusuf closed 1 year ago

SebghatYusuf commented 1 year ago

:information_source: Info

Version: v3.7.0

:speech_balloon: Description

I followed the steps described here to create a self signed pfx: [Flutter Desktop Documentation](https://docs.flutter.dev/development/platform-integration/windows/building#create-a-self-signed-pfx-certificate-for-local-testing: create self signed pfx)

Now when I run the command flutter pub run msix:create it throws this error:

Enter a description of your problem here.
Any logs, error and assets you have that can help to find this bug.
To run the tool with extended logs use the -v argument, for example: flutter pub run msix:create -v

[ +194 ms] executing: C:\Dev\flutter\bin\cache\dart-sdk\bin\dart __deprecated_pub --color run msix:create -v
[     0.025s] parsing cli arguments
[     0.236s] validating config values
[     0.252s] running "flutter build windows"...
[    34.715s] building msix files...
[    34.716s] validating build files
[    34.731s] cleaning temporary files
[    34.789s] create app icons
[    34.790s] generating icons
[    54.996s] copying VC libraries
[    55.018s] getting certificate publisher
[    55.019s] getting certificate "Subject" by file certificate
Unhandled exception:
ProcessException: The system cannot find the file specified.

  Command: powershell.exe -NoProfile -NonInteractive "new-object System.Security.Cryptography.X509Certificates.X509Certificate2(\"C:\Users\admin\projects\dvhdesktopapp\CERTIFICATE.pfx\",
        \"J#######\") | select -expandproperty Subject -First 1"
#0      _ProcessImpl._start (dart:io-patch/process_patch.dart:401:33)
#1      Process.start (dart:io-patch/process_patch.dart:38:20)
#2      _runNonInteractiveProcess (dart:io-patch/process_patch.dart:578:18)
#3      Process.run (dart:io-patch/process_patch.dart:49:12)
#4      SignTool._executePowershellCommand (package:msix/src/sign_tool.dart:81:21)
#5      SignTool._getCertificateSubjectByFile (package:msix/src/sign_tool.dart:136:53)
#6      SignTool.getCertificatePublisher (package:msix/src/sign_tool.dart:36:23)
#7      Msix._buildMsixFiles (package:msix/msix.dart:114:24)
<asynchronous suspension>
#8      Msix._createMsix (package:msix/msix.dart:98:5)
<asynchronous suspension>
#9      Msix.create (package:msix/msix.dart:57:5)
<asynchronous suspension>
#10     main (file:///C:/Users/admin/AppData/Local/Pub/Cache/hosted/pub.dev/msix-3.7.0/bin/create.dart:4:3)
<asynchronous suspension>
[+61147 ms] "flutter run" took 61,671ms.
[   +8 ms] pub finished with exit code 255
[   +2 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      _DefaultPub.interactively (package:flutter_tools/src/dart/pub.dart:586:7)
           <asynchronous suspension>
           #2      PackagesForwardCommand.runCommand (package:flutter_tools/src/commands/packages.dart:250:5)
           <asynchronous suspension>
           #3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1257:27)
           <asynchronous suspension>
           #4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #5      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
           <asynchronous suspension>
           #6      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:283:9)
           <asynchronous suspension>
           #7      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #8      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
           <asynchronous suspension>
           #9      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:64:9)
           <asynchronous suspension>
           #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #11     main (package:flutter_tools/executable.dart:91:3)
           <asynchronous suspension>

[ +140 ms] ensureAnalyticsSent: 134ms
[        ] Running 0 shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 255

:scroll: Pubspec.yaml

name: DVH
description: DVH APP

publish_to: "none" # Remove this line if you wish to publish to pub.dev

version: 1.0.0+1

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  camera: ^0.10.0+1
  country_code_picker: ^2.0.2
  cupertino_icons: ^1.0.3
  dart_ipify: ^1.1.0
  device_info_plus: ^3.0.1
  double_back_to_close_app: ^2.0.1
  easy_mask: ^2.0.1
  email_validator: ^2.0.1
  encrypt: ^5.0.0
  faker: ^2.0.0
  firebase_auth: ^3.6.3
  firebase_core: ^1.20.1
  flutter_font_icons: ^2.2.4
  flutter_spinkit: ^5.0.0
  fuzzywuzzy: ^0.1.7
  get: ^4.6.5
  google_fonts: ^3.0.1
  google_sign_in: ^5.0.4
  hive: ^2.0.5
  hive_flutter: ^1.1.0
  http: ^0.13.4
  image: ^3.0.4
  intl: ^0.17.0
  livechatt: ^1.2.0
  package_info_plus: ^1.3.0
  path: ^1.8.0
  path_provider: ^2.0.2
  permission_handler: ^8.3.0
  provider: ^6.0.3
  shared_preferences: ^2.0.6
  sign_in_with_apple: ^3.3.0
  system_info_plus: ^0.0.5
  url_launcher: ^6.0.6
  webview_flutter: ^3.0.0
  sklite:
    git: https://github.com/SebghatYusuf/SkLite-dart.git
  csv: ^5.0.1
  connectivity_plus: ^2.3.5
  sqflite: ^2.0.2+1
  pay: ^1.0.10
  flutterwave_standard: ^1.0.6
  uuid: ^3.0.6
  google_mlkit_text_recognition: ^0.4.0
  google_mlkit_commons: ^0.2.0
  dropdown_search: ^5.0.2
  shimmer: ^2.0.0
  firebase_analytics: ^9.3.3
  syncfusion_flutter_pdfviewer: ^20.2.48-beta
  auto_size_text: ^3.0.0
  firebase_in_app_messaging: ^0.6.0+27
  share_plus: ^4.5.3
  firebase_core_platform_interface: 4.5.1
  in_app_update: ^4.0.1
  in_app_review: ^2.0.6
  firebase_core_desktop: ^1.0.2
  firebase_auth_desktop: ^1.0.2
  flutter_svg: ^1.0.3
  cool_dropdown: ^1.4.2
  overlayment: ^0.2.1
  google_sign_in_dartio: ^0.2.2
  number_paginator: ^0.2.3
  in_app_purchase: ^3.1.5
  window_manager: ^0.3.1
  uni_links_desktop: ^0.1.6
  uni_links: ^0.5.1
  bot_toast: ^4.0.3

dependency_overrides:
  modal_bottom_sheet: ^3.0.0-pre

dev_dependencies:
  flutter_driver:
    sdk: flutter
  flutter_native_splash: ^1.2.4
  flutter_test:
    sdk: flutter
  integration_test:
    sdk: flutter
  hive_generator: ^1.1.1
  build_runner: ^2.1.5
  msix: ^3.7.0

flutter:
  uses-material-design: true

  assets:
    - assets/
    - images/
    - images/icons/
    - images/svg/

msix_config:
  display_name: DVH
  publisher_display_name: Vehicle Databases
  identity_name: vehicledatabases.dvh.app
  msix_version: 1.0.0.0
  logo_path: C:\Users\admin\projects\dvhdesktopapp\images\AppLogo.png
  start_menu_icon_path: C:\Users\admin\projects\dvhdesktopapp\images\AppLogo.png
  tile_icon_path: C:\Users\admin\projects\dvhdesktopapp\images\AppLogo.png
  capabilities: internetClient, location
  certificate_path: C:\Users\admin\projects\dvhdesktopapp\CERTIFICATE.pfx
  certificate_password: #######
  certificate_subject: CN=MY_CN
YehudaKremer commented 1 year ago

Are you sure the path to the certificate is current? Log: The system cannot find the file specified

SebghatYusuf commented 1 year ago

@YehudaKremer Sorry for the late reply, Yes the certificate exists in same the directory as logo (icon) and they're all using absolute paths.

iAndyHD3 commented 1 year ago

I just experienced the same issue and I found out why it happens and how to fix it:

The file it can't find is powershell.exe, which is not on always on PATH apparently, so the fix is simply adding the directory to PATH. In my case it's in C:\Windows\System32\WindowsPowerShell\v1.0

To fix this in the library I would

SebghatYusuf commented 1 year ago

@iAndyHD3 Thank you for your instructions, actually powershell was on PATH, issue was having anti virus on, and it was blocking the process.