Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/specs/cli-output-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Use `--format json --stream` to receive discovery results as NDJSON, with one co
{"path":"/path/to/ts-app/apphost.ts","language":"TypeScript","status":"possibly-unbuildable"}
```

Stream output is emitted in arrival order from parallel discovery; lines are not sorted. The non-streaming `--format json` snapshot above is sorted by `path`. If you need a deterministic order for streamed output, pipe through your own sort step (for example `jq -s 'sort_by(.path)'`).

If discovery finds no AppHost candidates, the stream emits no lines. The stream does not emit `started`, `complete`, or `canceled` control records; use the command's exit code and end-of-file to detect stream completion.

#### AppHost candidate fields
Expand Down
9 changes: 7 additions & 2 deletions src/Aspire.Cli/Commands/LsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,20 @@ private async Task<List<AppHostProjectCandidate>> FindAppHostsWithJsonStreamAsyn
{
var appHosts = new List<AppHostProjectCandidate>();

// `aspire ls --format json --stream` emits each candidate as soon as discovery surfaces
// it (arrival order from parallel discovery). The contract is documented in
// docs/specs/cli-output-formats.md. Do NOT sort here:
// candidates have already been written to stdout via WriteJsonStreamCandidate above, so
// any post-loop sort would only reorder this in-memory list — which the caller does not
// use for stream output. Pipe to `sort` / `jq -s 'sort_by(.path)'` for ordered output.
// See https://github.com/microsoft/aspire/issues/17621.
await foreach (var candidate in _projectLocator.FindAppHostProjectsStreamAsync(_executionContext.WorkingDirectory, scope, cancellationToken: cancellationToken).ConfigureAwait(false))
{
cancellationToken.ThrowIfCancellationRequested();
appHosts.Add(candidate);
WriteJsonStreamCandidate(CreateDisplayInfo(candidate));
}

appHosts.Sort((x, y) => string.Compare(x.AppHostFile.FullName, y.AppHostFile.FullName, StringComparison.Ordinal));

return appHosts;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ internal static async Task<IHost> BuildApplicationAsync(string[] args, CliStartu
var globalSettingsFilePath = GetGlobalSettingsPath(startupContext.Logger);
var globalSettingsFile = new FileInfo(globalSettingsFilePath);
var workingDirectory = new DirectoryInfo(Environment.CurrentDirectory);
ConfigurationHelper.RegisterSettingsFiles(builder.Configuration, workingDirectory, globalSettingsFile, startupContext.Logger);
ConfigurationHelper.RegisterSettingsFiles(builder.Configuration, workingDirectory, globalSettingsFile);

TrySetLocaleOverride(LocaleHelpers.GetLocaleOverride(builder.Configuration), startupContext.Logger, startupContext.ErrorWriter);
WarnIfGlobalSettingsContainAppHostPath(globalSettingsFile, startupContext.ErrorWriter);
Expand Down
203 changes: 178 additions & 25 deletions src/Aspire.Cli/Projects/ProjectLocator.cs

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions src/Aspire.Cli/Resources/ErrorStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/Aspire.Cli/Resources/ErrorStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,16 @@
<data name="CodegenDebugHeader" xml:space="preserve">
<value>Diagnostic details:</value>
</data>
<data name="ConfiguredAppHostPathHasInvalidCharacters" xml:space="preserve">
<value>The configured AppHost path in '{0}' ('{1}') is empty or contains characters that are not allowed in a file path.</value>
<comment>{0} is the configuration file path that the user authored, {1} is the field/setting name within that file (for example "appHost.path" or "appHostPath")</comment>
</data>
<data name="ConfiguredAppHostPathMustBeString" xml:space="preserve">
<value>The configured AppHost path in '{0}' ('{1}') must be a JSON string.</value>
<comment>{0} is the configuration file path that the user authored, {1} is the field/setting name within that file (for example "appHost.path" or "appHostPath")</comment>
</data>
<data name="ConfigurationFileMustBeJsonObject" xml:space="preserve">
<value>The configuration file '{0}' must contain a JSON object.</value>
<comment>{0} is the configuration file path that the user authored.</comment>
</data>
</root>
2 changes: 1 addition & 1 deletion src/Aspire.Cli/Resources/SharedCommandStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
<value>Include all candidate AppHosts, ignoring .gitignore and built-in directory filters</value>
</data>
<data name="LsStreamOptionDescription" xml:space="preserve">
<value>Stream newline-delimited JSON discovery events. Requires --format json</value>
<value>Output discovered AppHosts as newline-delimited JSON. Requires --format json</value>
</data>
<data name="LsStreamRequiresJson" xml:space="preserve">
<value>The --stream option requires --format json.</value>
Expand Down
15 changes: 15 additions & 0 deletions src/Aspire.Cli/Resources/xlf/ErrorStrings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions src/Aspire.Cli/Resources/xlf/ErrorStrings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions src/Aspire.Cli/Resources/xlf/ErrorStrings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions src/Aspire.Cli/Resources/xlf/ErrorStrings.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions src/Aspire.Cli/Resources/xlf/ErrorStrings.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions src/Aspire.Cli/Resources/xlf/ErrorStrings.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading