YehudaKremer / msix

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

[FEATURE REQUEST] Run an embbeded .exe in assets #248

Closed tototo23 closed 7 months ago

tototo23 commented 8 months ago

:speech_balloon: Description

I create a windows app in Flutter with an advanced UI, and at some point, my app calls an internal .exe file in the asset folder. When launching my app in dev, release, it works perfectly. But when installed with MSIX, it has rights issues :

C:\Program Files\WindowsApps\\data\flutter_assets\assets\software\App\ Always returns en exit code 1 in my Flutter app, because of access denied.

:question: Platform

Is there a wey to say to MSIX builder that there is an other .exe that should have the execution rights? Or is there a way to run a "post install bat script"? Or an other way to have the possibility to run make this embbeded .exe file runnable?

YehudaKremer commented 8 months ago

Hello @tototo23

Can you try call the .exe file like that: await File('${File(Platform.resolvedExecutable).parent.path}\myAssets\file.exe')......

YehudaKremer commented 8 months ago

After testing that is working, here more details.

  1. put all your .exe files in a folder (let call the folder "ExeFolder")
  2. put this folder in the Flutter build folder (you_project\build\windows\runner\Release)
  3. in your code, call your app with this path (full example):
    var pathToCsharpExecutableFile =
      '${File(Platform.resolvedExecutable).parent.path}\\ExeFolder\\TeoFlutterPoc.exe';
  4. run dart run msix:create and test your app.
tototo23 commented 8 months ago

Hi @YehudaKremer, thank you very much for that very fast answer and tests !

Actually, in my case, the issue doesnt come from the call of the app in Flutter, but the files hierarchy :
My built Windows project looks like :

Windows Release folder |- myMainApp.exe |- otherFilesLikeDLLEtc |- ... |- data/ | |- flutter_assets/ | | |- assets/ | | | |- ..|- .../ myOtherProgramToBeCalled.exe

Once this structure is packed in the msix, and then installed in Windows, I can find the same tree in C:\Program Files\WindowsApps\\data\flutter_assets\assets.... myOtherProgramToBeCalled.exe

The result is :

I have the same result inmy Flutter app : this asset file is totally found, but the execution is forbidden because of execution permission of the file itself

YehudaKremer commented 7 months ago

Hey

Windows block you from using other exe files other then the main one.

But, you can execute secondary exe files by open them from the main one code:

Process secondaryExe = await Process.start(secondaryExePath, []);
tototo23 commented 7 months ago

Thank you again @YehudaKremer

Actually it works before the MSIX, but not after. Event if it is not an exe calling an other exe :

In my example, i have the .exe file in data/flutter_assets/assets/.../secondary.exe

SO my problem a problem of calling the .exe from the main .exe, but the execution privilege of the .exe file installed via the MSIX -> it loses the execution permission only once installed as MSIX

YehudaKremer commented 7 months ago

Again

For MSIX app, windows uses virtual folders tree, and block any access you the app files.

if you want to use msix format, you open your secondary exe files through the main app process