Skip to content

Commit af65bae

Browse files
Add aspire ls command reference documentation
Documents the aspire ls command which discovers and lists AppHost project candidates, including: - Table and JSON output formats - Streaming mode (--format json --stream) and its ordering behavior - The --all flag for including all candidates - Configuration file path validation error messages Fixes noted in microsoft/aspire#17688 (backport of fixes L1-L5): - Stream output is emitted in arrival order (not sorted); non-streaming JSON output is sorted by path - Guidance on sorting streamed output with jq Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent dd13bce commit af65bae

2 files changed

Lines changed: 140 additions & 0 deletions

File tree

src/frontend/config/sidebar/reference.topics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ export const referenceTopics: StarlightSidebarTopicsUserConfig[number] = {
434434
slug: 'reference/cli/commands/aspire-export',
435435
},
436436
{ label: 'aspire init', slug: 'reference/cli/commands/aspire-init' },
437+
{ label: 'aspire ls', slug: 'reference/cli/commands/aspire-ls' },
437438
{
438439
label: 'aspire logs',
439440
slug: 'reference/cli/commands/aspire-logs',
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
---
2+
title: aspire ls command
3+
description: Learn about the aspire ls command which discovers and lists AppHost project candidates in the current directory and its subdirectories.
4+
---
5+
6+
import Include from '@components/Include.astro';
7+
8+
## Name
9+
10+
`aspire ls` - List AppHost project candidates.
11+
12+
## Synopsis
13+
14+
```bash title="Aspire CLI"
15+
aspire ls [options]
16+
```
17+
18+
## Description
19+
20+
The `aspire ls` command discovers and lists AppHost project candidates in the current working directory and its subdirectories. It performs parallel discovery and reports results along with each candidate's programming language and build status.
21+
22+
The default output is a human-readable table with the following columns:
23+
24+
| Column | Description |
25+
| ---------- | ------------------------------------------------ |
26+
| `PATH` | The file path to the AppHost project |
27+
| `LANGUAGE` | The programming language of the AppHost |
28+
| `STATUS` | Build status of the AppHost candidate |
29+
30+
### Discovery and configuration
31+
32+
If a configuration file (for example `aspire.config.json` with `appHost.path` or a legacy `aspireSettings.json` with `appHostPath`) points to an AppHost project, that path is included as a candidate. When the configured file path is absent, contains invalid characters, or is not a JSON string, a warning is displayed.
33+
34+
### Output ordering
35+
36+
**Non-streaming mode** (`--format json` without `--stream`): results are sorted by path before output.
37+
38+
**Streaming mode** (`--format json --stream`): results are emitted in arrival order from parallel discovery and are **not sorted**. If you need a deterministic order for streamed output, pipe through a sort step. For example:
39+
40+
```bash title="Aspire CLI"
41+
aspire ls --format json --stream | jq -s 'sort_by(.path)'
42+
```
43+
44+
## Options
45+
46+
The following options are available:
47+
48+
- **`--format <Json|Table>`**
49+
50+
Output result format. Use `Json` for machine-readable output suitable for scripting and automation. Defaults to `Table`.
51+
52+
- **`--stream`**
53+
54+
Output discovered AppHosts as newline-delimited JSON (NDJSON), emitting each candidate as soon as it is discovered. Requires `--format json`.
55+
56+
- **`--all`**
57+
58+
Include all candidate AppHosts, ignoring `.gitignore` and built-in directory filters.
59+
60+
- <Include relativePath="reference/cli/includes/option-help.md" />
61+
62+
- <Include relativePath="reference/cli/includes/option-log-level.md" />
63+
64+
- <Include relativePath="reference/cli/includes/option-non-interactive.md" />
65+
66+
- <Include relativePath="reference/cli/includes/option-nologo.md" />
67+
68+
- <Include relativePath="reference/cli/includes/option-banner.md" />
69+
70+
- <Include relativePath="reference/cli/includes/option-wait.md" />
71+
72+
## Examples
73+
74+
- List all discovered AppHost candidates in table format:
75+
76+
```bash title="Aspire CLI"
77+
aspire ls
78+
```
79+
80+
Example output:
81+
82+
```text title="Output"
83+
PATH LANGUAGE STATUS
84+
./src/MyApp.AppHost/MyApp.AppHost.csproj C# buildable
85+
./src/OtherApp.AppHost/OtherApp.AppHost.csproj C# buildable
86+
```
87+
88+
- Output discovered AppHosts as JSON for scripting:
89+
90+
```bash title="Aspire CLI"
91+
aspire ls --format json
92+
```
93+
94+
Example output:
95+
96+
```json title="Output"
97+
[
98+
{
99+
"path": "./src/MyApp.AppHost/MyApp.AppHost.csproj",
100+
"language": "C#",
101+
"status": "buildable"
102+
},
103+
{
104+
"path": "./src/OtherApp.AppHost/OtherApp.AppHost.csproj",
105+
"language": "C#",
106+
"status": "buildable"
107+
}
108+
]
109+
```
110+
111+
- Stream discovered AppHosts as newline-delimited JSON:
112+
113+
```bash title="Aspire CLI"
114+
aspire ls --format json --stream
115+
```
116+
117+
Example output (each line is a JSON object emitted as candidates are discovered):
118+
119+
```text title="Output"
120+
{"path":"./src/OtherApp.AppHost/OtherApp.AppHost.csproj","language":"C#","status":"buildable"}
121+
{"path":"./src/MyApp.AppHost/MyApp.AppHost.csproj","language":"C#","status":"buildable"}
122+
```
123+
124+
Note: lines are emitted in discovery arrival order and are not sorted. To sort streamed output by path:
125+
126+
```bash title="Aspire CLI"
127+
aspire ls --format json --stream | jq -s 'sort_by(.path)'
128+
```
129+
130+
- Include all AppHost candidates, ignoring `.gitignore` and directory filters:
131+
132+
```bash title="Aspire CLI"
133+
aspire ls --all
134+
```
135+
136+
## See also
137+
138+
- [aspire run](/reference/cli/commands/aspire-run/)
139+
- [aspire ps](/reference/cli/commands/aspire-ps/)

0 commit comments

Comments
 (0)