| name | pac-power-platform-cli |
| description | Use the Microsoft Power Platform CLI (`pac`) to manage Dataverse environments, authentication profiles, and solutions (export / import / unpack / pack / clone), plus PCF, plug-ins, and Power Pages. Trigger whenever the user wants to work with Power Platform / Dataverse / Power Apps from the command line, do solution ALM / source control, or asks about a `pac ...` command. |
Power Platform CLI (pac)
pac is Microsoft's official command-line tool for Power Platform / Dataverse.
It manages authentication, environments, solutions (ALM), and developer
components (PCF, plug-ins, Power Pages, code apps). Installed as a .NET global
tool at ~/.dotnet/tools/pac.
Official reference: https://learn.microsoft.com/power-platform/developer/cli/reference/
When to use this skill
- Connecting to a Dataverse tenant/environment or switching between them.
- Solution lifecycle: export, import, unpack/pack (source control), clone, sync,
version, publish, check, upgrade.
- Scaffolding/pushing developer components:
pcf, plugin, pages.
- Any request phrased as "run
pac ..." or "using the Power Platform CLI".
First: orient yourself before acting
Auth and environment state is global to the machine, so always confirm context
before running any command that writes to Dataverse:
pac auth list
pac auth who
pac env list
Key gotcha: a profile can be authenticated but have no active environment
selected (the Active column in pac env list is blank). Import/export/publish
commands need a target — set one first:
pac env select --environment <URL | ID | unique-name | partial-name>
Almost every write command also accepts a per-invocation --environment (-env)
override, so you don't have to change the global selection if you only need it once.
Core command groups
| Group | Purpose |
|---|
pac auth | Authentication profiles (create, list, select, delete, who) |
pac env | Environments (list, select, who, fetch, settings) |
pac solution | Solution ALM — the most-used group |
pac pcf | Power Apps Component Framework projects |
pac plugin | Dataverse plug-in class libraries |
pac pages | Power Pages websites (download / upload) |
pac pipeline | Deployment pipelines |
pac tool | Launch companion GUIs (PRT, CMT, Package Deployer) — Windows/.NET Full only |
pac data | Import/export Dataverse data |
pac admin | Tenant/admin operations (create/copy/backup envs, service principals) |
See all: pac help. See one group's verbs: pac <group> help. See a verb's full
options: pac <group> <verb> help (e.g. pac solution export help).
Authentication
pac auth create --name Contoso-Dev --environment "HR-Dev"
pac auth create --name Contoso-SPN \
--applicationId <appId> --clientSecret <secret> --tenant <tenantId>
pac auth create --environment <envId> --deviceCode
pac auth list
pac auth select --index 2
pac auth name --index 1 --name "Contoso Dev"
pac auth delete --index 2
pac auth clear
Notes:
- Use
--environment (accepts ID, URL, unique name, or partial name). --url is
deprecated — and using --url creates a DATAVERSE-kind profile rather than a
UNIVERSAL one, which some commands (e.g. power-fx) reject.
- Cloud values for sovereign clouds: GCC=
UsGov, GCC High=UsGovHigh, DoD=UsGovDod
(via --cloud).
Solution ALM — the primary workflow
The canonical source-control loop: export → unpack → commit → (edit) → pack → import.
pac solution list
pac solution export --name MySolution --path ./out --managed
pac solution export --name MySolution --path ./out
pac solution unpack --zipfile ./out/MySolution.zip --folder ./src --packagetype Both
pac solution pack --zipfile ./MySolution.zip --folder ./src --packagetype Managed
pac solution import --path ./MySolution.zip --environment <target URL|ID>
Other useful solution verbs:
pac solution init --publisher-name Contoso --publisher-prefix con
pac solution clone --name MySolution
pac solution sync
pac solution version --revision 1
pac solution publish
pac solution check --path ./MySolution.zip
pac solution upgrade --solution-name MySolution --async --max-async-wait-time 60
pac solution delete --solution-name MySolution
unpack/pack format nuance (important)
- Default
pac solution unpack produces the classic XML layout
(Other/Solution.xml, Controls/, etc.).
- Solutions from Dataverse Git integration or
pac solution clone use the newer
YAML layout under solutions/<Name>/ (solution.yml, solutioncomponents.yml,
...). YAML support requires CLI ≥ 2.4.1.
- To repack YAML, use
pac solution pack --folder <root> — the presence of a
solutions/ subdirectory auto-selects YAML. Putting YAML files at the repo root
instead causes a misleading "missing Customizations.xml" error.
unpack, clone, and sync do not currently emit YAML on their own; only
Git integration and clone produce the YAML layout that pack can consume.
pac solution supersedes the old standalone SolutionPackager.exe — same engine,
now built into the CLI.
Developer components (quick reference)
pac pcf init --namespace Contoso --name MyControl --template field
pac plugin init
pac plugin push --pluginId <assembly-or-package-id>
pac pages download --path ./site --webSiteId <id>
pac pages upload --path ./site
Environment data / queries
pac env who
pac env fetch --xml "<fetch>...</fetch>"
pac env list-settings --filter <name>
pac data export / pac data import
CI/CD without installing globally
With .NET 10+, run any command without a global install (good for pipelines):
dnx Microsoft.PowerApps.CLI.Tool --yes env list
Practical tips
- Prefer the solution unique Name (not display name) everywhere it's requested.
- Add
--json to admin/list commands to get machine-readable output for scripting.
- Long operations: many verbs accept
--async + --max-async-wait-time <minutes>.
pac tool ... GUIs (Plugin Registration Tool, Configuration Migration, Package
Deployer) are Windows / .NET Full Framework only — not available on macOS/Linux.
- Discover options interactively with the layered help:
pac, pac <group> help,
pac <group> <verb> help.
Safety
Import, publish, delete, upgrade, and any pac admin write command mutate a live
environment. Before running one, confirm the active auth profile and target
environment (pac auth who) so you don't push changes to production by mistake.
When the intended target differs from the active one, pass --environment
explicitly rather than relying on global state.