# Install and verify the AppPortal CLI

Install the AppPortal CLI, register builds and managed symbols, upload distribution artifacts, and choose the right credential for CI or MCP.

Source: https://appportal.io/docs/api/cli-install

Use the `appportal` CLI to inspect builds, upload artifacts and symbols, or run the local MCP server.
Install the **.NET 10 SDK** first. For Alpha, use the package source and version provided with your access.

## Install the tool

```bash
dotnet tool install --global AppPortal.Cli --version "<VERSION>" --configfile "<NUGET_CONFIG>"
```

Replace the placeholders with the package version and the path to a NuGet configuration for your
approved source. Ask your Alpha onboarding contact for the source and version if you need them.

## Verify PATH and installation

Open a new terminal, then run:

```bash
dotnet tool list --global
appportal --help
appportal build inspect . --json
```

The list should contain `AppPortal.Cli` and the command `appportal`.
Run inspection from your project or artifact directory to obtain its platform/build metadata;
inspection does not upload anything. If the shell cannot find the command, add the .NET global-tool
directory to PATH: `$HOME/.dotnet/tools` on macOS/Linux or `%USERPROFILE%\.dotnet\tools` on Windows.
Restart the MCP client after changing PATH.

## Choose the credential for the task

| Task | Credential | Where it belongs |
| --- | --- | --- |
| Send telemetry from an app | SDK client key | Supported SDK configuration |
| Register builds and upload symbols or app artifacts | App/environment-bound upload credential | `APPPORTAL_UPLOAD_KEY` in the upload step |
| Publish an uploaded artifact to a release channel | Server API credential with `ReleasePublish` | `APPPORTAL_SERVER_KEY` in a protected publication step |
| Connect an agent through MCP | Interactive OAuth profile | The CLI's local credential store |

Create an upload credential in **App settings → CI uploads**. Keep secrets in your CI secret store;
do not commit them to `appportal.json`, pass them in command arguments, or print them in logs.
OAuth login does not supply an upload key, and an SDK client key cannot replace one.

## Inspect, register, or upload a build

| Command | Result |
| --- | --- |
| `appportal build inspect` | Inspect local build identity without a network request |
| `appportal build register` | Register identity and upload symbols without an installable app artifact |
| `appportal build exclude` | Register a build excluded from telemetry ingestion |
| `appportal build release` | Register identity, upload symbols, and attach an IPA, APK, AAB, or Windows ZIP |
| `appportal upload` | Alias for `appportal build release` |

Build commands take a project directory or artifact path. Use `--bundle-id`, `--app-version`,
`--build-number`, `--platform`, and `--project-type` to supply the identity your build actually uses.
Set `APPPORTAL_UPLOAD_URL` to your deployment’s Upload origin, or pass it with `--server`.
Use `--environment` for the app environment bound to your upload credential.

For an Android artifact, validate locally before uploading:

```bash
appportal build release ./artifacts/app.apk \
  --environment production --dry-run --json
```

Remove `--dry-run` to upload using `APPPORTAL_UPLOAD_KEY`. Add `--symbols` with the matching
symbol directory and `--strict-symbols` when missing uploadable symbols must fail the job.
An artifact upload stays a draft unless you request publication. See
[Upload and publish a test build](https://appportal.io/docs/guides/distribution) for recipient verification.

## Standalone Upload configuration

For Production, set the Upload origin once in your shell:

```bash
export APPPORTAL_UPLOAD_URL=https://upload.appportal.io
```

You can also set `uploadUrl` in `appportal.json`. An explicit `--server` takes precedence.
Older CLI versions can still use their configured Downloads compatibility endpoint.

For an explicit artifact-registration retry, retain the same `--idempotency-key` and unchanged
artifact metadata. Matching server support is required for replay. This does not make the complete
upload/publication command atomic or let an upload credential publish: group publication still uses
the separate Automation origin and server credential with `ReleasePublish`.

## Upload managed Release symbols

Keep the optimized Release assembly and its external Portable PDB from the same build.
For a managed Linux app, register both without uploading an installable artifact:

```bash
appportal build register ./artifacts/managed \
  --symbols ./artifacts/managed \
  --platform linux --project-type dotnet \
  --bundle-id com.example.myapp --app-version 1.0.0 --build-number 42 \
  --environment production --managed-symbols --configuration Release \
  --strict-symbols --dry-run --json
```

Replace the sample identity with your actual build identity. Remove `--dry-run` for the upload.
`--configuration Release` declares the uploaded profile; it does not compile the app.
`--managed-symbols` selects the verified managed Release profile; hosted Debug and embedded PDB
uploads are unsupported. Keep each build's symbol output separate from other configurations.
The service checks module/debug identities and hashes from uploaded bytes; version labels do not
select a substitute pair. Omitting `--managed-symbols` uses the legacy symbol path and does not
establish a verified managed pair.

The JSON `managedSymbols` results report `pending-pair` or `pair-verified` for each uploaded file.
The first file can be pending until its counterpart arrives. Pair verification does not mean every
crash frame resolves: inspect **Symbols** and **Processing** separately on the occurrence.
Preserve unresolved frames and compare the exact reported build. Registration support and installable
artifact support are separate; a Linux registration does not upload a Linux distribution package.

Follow [Upload builds and managed symbols from CI](https://appportal.io/docs/guides/cli-ci-uploads) for GitHub Actions
and Azure Pipelines examples, credential mapping, and failure recovery.

## Select the deployment and app environment

`--server` selects the AppPortal deployment. `--environment` selects an environment **inside your app**;
it does not switch deployments. Keep the upload credential, Upload service, and publication
credential on the same deployment.

| Deployment | Upload service | Automation service for publication |
| --- | --- | --- |
| Stage | `https://upload.stage.appportal.io` | `https://automation.stage.appportal.io` |
| Production | `https://upload.appportal.io` | `https://automation.appportal.io` |

These credential-free checks use a fictional app's `qa` environment on Stage and `production`
environment on production. Replace each environment with the one bound to your upload credential:

```bash
appportal build release ./artifacts/app.apk \
  --server https://upload.stage.appportal.io --environment qa --dry-run --json

appportal build release ./artifacts/app.apk \
  --server https://upload.appportal.io --environment production --dry-run --json
```

For channel publication, set `APPPORTAL_AUTOMATION_URL` to the Automation origin in the same row.
A dry run validates local build inputs and command options; it does not contact either deployment,
verify credential permissions, or prove that a service URL is reachable.

## Manage release channels

Create release channels and manage their recipients in the app's **Distribution groups** drawer.
Copy the intended group IDs into `--groups`; the CLI publishes an uploaded artifact to those existing
channels. It does not create channels or change recipients. Use the portal to review membership and
release state before publication. See [Upload and publish a test build](https://appportal.io/docs/guides/distribution).

## Authenticate for MCP

```bash
appportal auth login
appportal auth status
```

Complete the browser sign-in and select the intended organization, apps, and permissions.
The CLI stores and refreshes the OAuth session for your OS user. For a named profile:

```bash
appportal auth login --profile appportal-test
appportal auth status --profile appportal-test
```

Then follow [Connect MCP clients](https://appportal.io/docs/api/mcp-clients). The client launches
`appportal mcp --profile appportal-test` over stdio. Do not paste tokens into an MCP configuration.

## Update or diagnose a failure

```bash
dotnet tool update --global AppPortal.Cli --version "<VERSION>" --configfile "<NUGET_CONFIG>"
```

An unknown `auth` command indicates an older CLI: update it before following MCP recipes.
A valid local inspection with failed remote tools usually
means the selected profile needs login or lacks the relevant permission.
Use `appportal auth status` for that same profile before retrying.
