Hello dear community members. I really need your help figuring out Power Apps / Power Automate Solution Packages work. I can't figure how to to generate a proper ZIP solution that is understood by the Power Platform during the import process.
What I am trying to do
- Manually. Export a solution that contains Power Apps, Power Automate as a ZIP file.
- Unzip the ZIP file programmaticaly.
- Perform a minor change in several unzipped files.
- ZIP up the files back to a solution programmatically, using PowerShell,
- Import Solution (zip) file to a new/same environment.

I have an issue with the Step #4 - Zipping the solution files back to a solution file. To be more specific, the issue is in the step #5. When I generate a ZIP file programmatically, Step #5 fails. When I create a ZIP file manually (see screenshot below) - Step #5 succeeds.
Experiment A) If we manually create a solution file, then Step #5 works as expected: I can import a solution file with no issues:

Manually Zip solution file is imported perfectly fine:

Experiment B) However, I am trying to automate the entire process and do not want to manually ZIP anything. So, I am ZIPping the solution files using PowerShell:

As a result of running this PowerShell script, I get a ZIP solution file. It looks completely valid and I don't see any issues with it.
So, now, I am trying to import this solution file via https://make.powerapps.com/, but this time I get an error:
Solution "ContosoSolution" failed to import: Error while importing workflow {ed432f3c-6ee6-ea11-a817-000d3af41a7c} type ModernFlow name PowerApp -> Get items: Workflow import: Xaml file is missing from import zip file: FileName: /Workflows/PowerApp-Getitems-ED432F3C-6EE6-EA11-A817-000D3AF41A7C.json
This is what the solution import log contains:

According to the error, the solution ZIP file is missing a /Workflows/....json file. This error seems to be misleading, because the ZIP file does contain this file:

Question how can I generate a solution file programmatically in a way that can be properly read by the Power Platform during the import process? Why generating ZIP files manually works while programmatic generation causes an issue?
How to quickly replicate an issue
- Export solution package
- Unzip it
- ZIP it back using PowerShell:
[System.IO.Compression.ZipFile]::CreateFromDirectory($SourceDirectory, "PowerShell-Optinal-UTF8.zip",
[System.IO.Compression.CompressionLevel]::Fastest, $false, [System.Text.Encoding]::UTF8 )
- Import the ZIP Solution file
- Result: Get an error
More details
- Why I am asking this question? I am trying to upgrade the Power Apps / Flow migrator script to also support Solution migration.
- I was trying to ZIP the file:
- With UTF8 encoding
- With different compressions:
- Uncompressed
- Fastest
- Optimal
- Was trying to Compress-Archive PowerShell cmdlet and [System.IO.Compression.ZipFile]::CreateFromDirectory .NET function.

