It often happens when you’re working on one problem, you figure something out, without completely solving your original problem.
I was trying to do some automated build and deployment of scripts into Powerapps, which I thought would be a pretty simple implementation but ended up requiring some extra and interesting work.
For all of this, I used the PAC Toolkit (available as an extension in VsCode)
Exporting your Solution from PowerApps with PAC
First off, connect to your desired tenant (this will force a login screen to be opened).
pac auth create --environment https://YOURTENANTHERE.crm3.dynamics.com/
When you have completed that, you can then export your solution to your desired path. The use of the async command gives you some progress indications as to how it is going.
pac solution export --name MySuperCoolSolution --path ./Solutions/MySuperCoolSolution.zi
p –async
And lastly, you will want to open your solution and add some files so you will need to unpack it.
pac solution unpack --zipfile ./Solutions/MySuperCoolSolution.zip --folder ./Solutions/unpack/MySuperCoolSolution/
At this point, you have a solution that has been exported from PowerApps that you are free to work with.
Re-Importing your Solution
If you are doing this step separately, you will need to create your initial authorization, but if not, you can skip it. The first thing we now need to do is re-pack your solution, where we essentially put it all back together.
pac solution pack --folder ./Solutions/unpack/MySuperCoolSolution --zipfile ./Solutions/MySuperCoolSolution.zip
pac solution import --path ./Solutions/MySuperCoolSolution.zip --publish-changes --force-overwrite --async
You don’t have to use the –async parameter but I recommend it if you don’t have a stable connection.
Putting it All Together
Now the above wasn’t my final goal, but where I took it next in my infinite laziness was that 2 or 3 commands to remember and type was too much, so I added this into two PowerShell scripts where I could simply pass in the Environment and Solution name and be able to run.
Import.ps1
param (
/
[string]$Environment,
[string]$Solution = "Release"
)
Write-Output "Environment: $Environment"
Write-Output "Solution: $Solution"
pac solution pack --folder ./Solutions/unpack/$Solution --zipfile ./Solutions/$Solution
$Solution.zip
/
pac solution import --path ./Solutions/$Solution
$Solution.zip --publish-changes --force-overwrite --async
Export.ps1
param (
[string]$Environment,
[string]$Solution
)
Write-Output "Environment: $Environment"
Write-Output "Solution: $Solution"
# Example command placeholder:
pac auth create --url $Environment
pac solution export --name AllInOne --path ./Solutions/$Solution --async
pac solution unpack --zipfile ./Solutions/$Solution/$Solution.zip --folder ./Solutions/unpack/$Solution
For either script, it’s then a simple task of calling it from the command line and letting it run.

And you can see that it unpacked everything in my solution.
