0

We have several SharePoint Online List form Power Apps. We export and import them to different site collections in our tenant [DEV/TEST/ACCEPTANCE/PROD]. This requires to change the datasources.json file that is in the zip file when you export the app. We use a script to achieve this. This script unzips the export, unzips the .msapp file. changes the datasources.json file in the .msapp file and makes a new .msapp file with zip. We rezip the entire app which we import in Power Platform. This was working fine.

We now moved to PowerShell 7 on our dev machines. Since this change the zip file can be imported but the app doesn't work after import. We get a file not found error when editing the app. When we revert back to PowerShell 5 the app can be imported and works fine.

We make use of the default Compress-Archive cmdlet to zip the file. When inspecting the zip files we see that there is a difference. When we user Compress-Archive in PowerShell 5 file paths are combined using a "". In PowerShell 7 file paths are combined using a "/".

Why can't we import a zip file that is using "/" as a seperator? I think both should work.

2
  • Did you check my answer?
    – jleture
    Dec 11, 2023 at 15:23
  • Not yet. I am importing a new app this week. So I will accept your anwser this week when it works.
    – Danny
    Dec 11, 2023 at 22:26

2 Answers 2

1

The best practice is to use pack/unpack features of Power Platform CLI.

But, as your initial question is about to zip/unzip, it's better to use tools like 7Zip or tar. Native PowerShell (Compress-Archive) or .NET function ([System.IO.Compression.ZipFile]::CreateFromDirectory) will not work as the file will not be recognized.

Sample to recreate a zip with tar:

tar -a -c -f "my-powerapps.zip" *

Sample to recreate a zip with 7Zip in PowerShell:

$aZipfile = "my-powerapps.zip"
$aDirectory = "C:\repos\my-powerapps\"
[string]$pathTo7ZipExe = "$($Env:ProgramFiles)\7-Zip\7z.exe"
[Array]$arguments = "a", "-tzip", $aZipfile, $aDirectory, "-r"
& $pathTo7ZipExe $arguments

Tested with my team for years, but now you use PAC CLI!

5
  • I am updating my question because this anwser doesn't work for TAR. Zipping with 7zip works with the GUI version. I am going to test with the cmd line version. I should explain that we are also unzipping the .msapp file and rezipping it. This is the file that causes the app to fail after import. We can import the zip but when editing the app we get file not found error. With 7zip GUI we can rezip the .msapp file and it works
    – Danny
    Dec 12, 2023 at 22:11
  • I tested with the cmd line 7zip. It doesn't work for the .msapp file. The GUI of 7zip does work and makes a correct zip file
    – Danny
    Dec 12, 2023 at 22:32
  • Correction. It seems that also the GUI version corrupts the .msapp file.
    – Danny
    Dec 12, 2023 at 22:35
  • Of course PAC CLI is the best practice but your question was to zip/unzip and using 7Zip or tar is a working solution (tested by my team for years before we migrate to PAC CLI)
    – jleture
    Dec 13, 2023 at 6:31
  • 1
    Sorry for the confusion and thanks for your input.
    – Danny
    Dec 13, 2023 at 10:25
0

I found this post on StackOverflow: https://stackoverflow.com/questions/77501267/how-to-authomatically-modify-msapp-files-using-azure-function-apps

It pointed me in the direction of this dotnet Power Platform CLI tool: https://github.com/microsoft/PowerApps-Language-Tooling/blob/master/README.md

I am now unpacking and packing my .msapp file using this tool and rezipping the app using Compress-Archive and I can import, edit and publish my app.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.