msix
After comparing different methods, I think the most stable way is using
msix to package the windows desktop app.
Installation
flutter pub add --dev msix
self-signed certificate
To create an installer for your desktop app project, you need a certificate for your app. Let’s use OpenSSL to create one.
download
After downloading and installing OpenSSL, add path-to-OpenSSL-Win64\bin to your environment variable.
create certificate
Run the following commands step by step then you can obtain the certificate.
$ openssl genrsa -out mykeyname.key 2048
$ openssl req -new -key mykeyname.key -out mycsrname.csr
$ openssl x509 -in mycsrname.csr -out mycrtname.crt -req -signkey mykeyname.key
$ openssl pkcs12 -export -out CERTIFICATE.pfx -inkey mykeyname.key -in mycrtname.crt
msix_config
Let’s add the msix settings in pubspec.yaml .
The most important part are the certificate_path and certificate_password .
Pakage app
flutter pub run msix:create
It would take a while to package the project. Then you would obtain a msix file, this is the installer of the app.
Trusted Root Certification Authorities
Before using this installer to install your app, you need to add the certificate of this installer into the Trusted Root Certification Authorities of your pc. Since you use a self-signed certificate, windows don’t trust it by default.
choose Properties
choose Digital Signatures
choose your certificate then choose Details
click Install Certificate… to install
choose Local Machine
choose Trusted Root Certification Authorities
Finally, click ok and ok. Then you should be able to use this installer.