Essential PAC CLI Commands Every Power Apps Developer Should Know

Juan Carlos Santiago
Essential PAC CLI Commands Every Power Apps Developer Should Know
The Power Platform CLI (PAC CLI) is a game-changer for Power Apps developers who want to work more efficiently and implement proper source control practices. Whether you're managing solutions, working with canvas apps, or connecting to Dataverse, understanding these essential commands will transform your development workflow.
Installing the PAC CLI
Before you can harness the power of the command line, you need to install the CLI on your machine. The process is straightforward:
dotnet tool install --global Microsoft.PowerPlatform.CLI
If you already have it installed and need to update to the latest version:
dotnet tool update --global Microsoft.PowerPlatform.CLI
Verify your installation by checking the version:
pac --version
Authenticating to Your Environments
Authentication is the foundation of all PAC CLI operations. The pac auth command family handles this critical task.
Create a New Authentication Profile
pac auth create --url https://yourorg.crm.dynamics.com
This command will prompt you to log in with your Microsoft account. The CLI stores your authentication profile for future use.
List All Authentication Profiles
pac auth list
This shows all your configured environments, helping you manage multiple environments if you work across development, staging, and production.
Select an Active Environment
pac auth select --index 1
Use the index number from your auth list to switch between environments quickly.
Delete an Authentication Profile
pac auth delete --index 1
Working with Solutions
Solutions are the packaging mechanism for Power Apps customizations. The PAC CLI makes solution management seamless.
Export a Solution
pac solution export --path ./MyExportedSolution.zip
Add the --managed flag to export as a managed solution:
pac solution export --path ./MyManagedSolution.zip --managed
Import a Solution
pac solution import --path ./MyExportedSolution.zip
Include --force-overwrite if you want to overwrite existing components:
pac solution import --path ./MyExportedSolution.zip --force-overwrite
Clone a Solution
Cloning is perfect for creating a copy with a new name:
pac solution clone --name OriginalSolution --clone-name NewSolution
Unpack a Solution
Unpacking extracts a solution into source-control-friendly XML files:
pac solution unpack --zipfile ./MyExportedSolution.zip --outputdir ./MyUnpackedSolution
Pack a Solution
After making changes to your unpacked files, pack them back into a zip:
pac solution pack --inputdir ./MyUnpackedSolution --outputfile ./MyPackedSolution.zip
Managing Canvas Apps Locally
Canvas apps can now be developed with proper version control using the PAC CLI.
List All Canvas Apps in Your Environment
pac canvas list
Download a Canvas App
pac canvas download --appId "your-app-id" --outputdir ./MyCanvasApp
Upload Your Canvas App
pac canvas upload --inputfile ./MyCanvasApp.msapp
Connecting to Dataverse
The pac data commands let you interact directly with Dataverse.
Create a Table Reference
pac data create --table accounts --data '{"name":"Test Account"}'
Query Records
pac data query --table accounts --filter "name eq 'Test Account'"
A Practical Workflow Example
Here's how these commands come together in a real development scenario:
# 1. Authenticate to your development environment
pac auth create --url https://dev.crm.dynamics.com
# 2. Create a new solution
pac solution new --name MyNewSolution
# 3. After development, export your solution
pac solution export --path ./MyNewSolution.zip
# 4. Unpack it for source control
pac solution unpack --zipfile ./MyNewSolution.zip --outputdir ./src/MyNewSolution
# 5. (Your team makes changes and commits to git)
# 6. Switch to staging environment
pac auth select --index 2
# 7. Pack your solution
pac solution pack --inputdir ./src/MyNewSolution --outputfile ./MyNewSolution.zip
# 8. Import to staging
pac solution import --path ./MyNewSolution.zip --force-overwrite
Pro Tips
Batch Operations: Chain commands together for efficient workflows using bash scripts or PowerShell.
Source Control: Always unpack solutions before committing to git. This enables proper diff tracking and merge conflict resolution.
Environment Consistency: Use the same development workflow across your team by documenting your PAC CLI commands in a README file.
Automation: Integrate PAC CLI commands into your CI/CD pipelines using GitHub Actions or Azure DevOps for automated deployments.
Mastering the PAC CLI transforms you from a manual clicker to an efficient, automation-focused developer. Start with authentication and solution management, then expand into canvas app development and Dataverse operations. Your future self will thank you when you're deploying changes in seconds instead of minutes.
