YehudaKremer / msix

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

[FEATURE REQUEST] Support for config path in the msix creation command #220

Open milindgoel15 opened 1 year ago

milindgoel15 commented 1 year ago

:speech_balloon: Description

As per the docs, the config node has to be present in the pubspec file. Can you add support for custom config files and declaring paths in the command to use such config files? For example,

root > config > msix_config.yaml

the command would be: dart run msix:create --config=config/msix_config.yaml

of course the config path will be optional, keeping default check to be in pubspec.

:question: Platform

Is this feature request for a specific platform? E.g. Web / iOS / Android / Mac OS / Windows / Linux N/A

milindgoel15 commented 1 year ago

I was able to implement this. will create a PR soon.

praxamarnix commented 1 year ago

This would be great, since I have a couple of variables that are build dependent. For example, I want to send a different type of --dart-fine="SOMESTUFF=$1". Meaning that I will have to generate that in some script before sending it over.

Or would it already be possible to add this in the dart command as an optional parameter?

milindgoel15 commented 1 year ago

For example, I want to send a different type of --dart-fine="SOMESTUFF=$1".

Can you provide an example for this? Some kind of flavor?

praxamarnix commented 1 year ago

For example I want to be able to send a dart-define into the windows_build_args. That would not be possible with only pubspec.yaml. Or otherwise I will have to generate pubspec.yaml just before compilation as a workaround.

In this example I'm trying to set a database that could be either development or production. But one could also think of secrets that need to be compiled into the code.

msix_config:
  windows_build_args: --dart-define="DATABASE=production"
milindgoel15 commented 1 year ago

Understood what you meant. Might be possible but have to test it. Would you be able to provide an example repository?

praxamarnix commented 1 year ago

I was able to reproduce with the following steps:

That will do. When I run dart run msix:create I see the following output:

$ dart run msix:create
Building package executable... (2.4s)
Built msix:create.
running "flutter build windows --dart-define=DATABASE=production"... 38.4s
building msix files...                 0.8s
packing msix files...                  3.2s

So it it definitely working in that sense. But I want the --dart-define to be more flexible and not hard-coded in my pubspec.yaml as described here in this ticket as well.

milindgoel15 commented 1 year ago

But I want the --dart-define to be more flexible and not hard-coded in my pubspec.yaml as described here in this ticket as well.

As an update to this specific feature request, I have added the way to define variables for --dart-define but in the form of a command option since we cannot modify the yaml files on demand. So the choice will work in the way of flavours.

example:

msix_config-production:
   display_name: msixflavor
   publisher_display_name: test
   identity_name: com.example.msixflavor
   msix_version: 1.0.0.0
   windows_build_args: --dart-define="DATABASE=production"

msix_config-development:
   display_name: msixflavor
   publisher_display_name: test
   identity_name: com.example.msixflavor.dev
   msix_version: 1.0.0.0
   windows_build_args: --dart-define="DATABASE=development"

So with the sample example, the commands will be like these respectively.

dart run msix:create --values="production"
dart run msix:create --values="development"

Only the config node and value in the command has to be kept same, rest all can be anything. msix_config-dev === --values="dev"

Will add the new changes to my current PR

praxamarnix commented 1 year ago

I don't know if this is really needed. I would probably just generate the config.yaml file on the fly before building in a shell/cmd script and then tell msix where to find it.

If you have these flavors, you can imagine tons of combinations, which are easier to supply with multiple config files.

milindgoel15 commented 1 year ago

I find it easier to just write all the configs I need before the creation or at the time of the creation of the project. So running the dart run msix:create command or any other command for other packages becomes easier because you don't need to generate/modify yaml files again and again.

Even with scripts, I personally use make to generate build output files so I just do make windowsbuild and I am done. Never generating/modifying existing yaml again. Just my approach so I implemented your feature request in the way I thought its better.

YehudaKremer commented 9 months ago

Hello, Sorry for responding so late.

Please read my comment: https://github.com/YehudaKremer/msix/pull/223#issuecomment-1811229480 and the alternative option by using "Command-line argument".