Flutter Desktop Windows / msix
(自分メモ)久々Flutterだが目的はmsixインストーラの作成
環境
Windows 11 (msixを作成するには開発者モード有効化が必要)
管理者コマンドプロンプト
start ms-settings:developers
// 開発者モード➔有効
- Flutter SDK 3.3.4
- VSCode + Flutter plugin (F1➔Flutter doctor➔☑Windows(desktop)を確認)
プロジェクト履歴
プロジェクト作成
VSCode➔F1➔Flutter New Project
MSI作成パッケージ追加
flutter pub add --dev msix
pubspec.yaml - MSIX用設定
msix_config:
display_name: Flutter App
msix_version: 1.0.1.0
certificate_path: build\mycertificate.pfx // 署名ファイルを指定
certificate_password: changeit // 署名ファイルのエクスポートパスワード
デバッグ実行
VSCode➔
F1➔Flutter:Select Device
F5
ビルド
flutter build windows
build\windows\runner\Release
以下に.exeファイルが生成される。
ビルド・msixパッケージ作成
flutter pub run msix:create
// 署名を要求される。テスト用署名(test_certificate.pfx)生成を選択。
build\windows\runner\Release
以下に.msixファイルが生成される。
自己署名の生成とWindowsに登録
bash:オレオレ署名作業
cd build
openssl genrsa -out mysecret.key 2048
openssl req -new -key mysecret.key -out certsignreq.csr
openssl x509 -in certsignreq.csr -out mycertificate.crt -req -signkey mysecret.key -days 3650
openssl pkcs12 -export -out mycertificate.pfx -inkey mysecret.key -in mycertificate.crt
生成された.pfxファイルをダブルクリック➔証明書のインストール➔信頼されたルート証明機関に登録
参照