Skip to content

Add JSON output to dotnet sln list - #56808

Merged
marcpopMSFT merged 4 commits into
mainfrom
copilot/implement-format-option-for-sln-list
Nov 5, 2026
Merged

marcpopMSFT merged 4 commits into
mainfrom
copilot/implement-format-option-for-sln-list

Conversation

Copilot AI commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

dotnet sln list includes headers that prevent direct consumption by automation. This change adds machine-readable output without changing the default display.

  • Output formats

    • Add --format <table|json>, defaulting to table.
    • JSON emits a sorted array of project paths, or [] for empty solutions.
    • Support solution filters and --solution-folders.
  • CLI integration

    • Update help text and localization resources.
    • Use source-generated JSON serialization for Native AOT compatibility.
dotnet sln source.sln list --format json
# ["App/App.csproj","Lib/Lib.csproj"]

@azure-pipelines

azure-pipelines Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI linked an issue Oct 27, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add --format option to dotnet sln list command Add JSON output to dotnet sln list Oct 27, 2026
Copilot AI requested a review from marcpopMSFT October 27, 2026 20:41
@Frulfump Frulfump mentioned this pull request Oct 27, 2026
3 of 4 tasks
@marcpopMSFT
marcpopMSFT marked this pull request as ready for review November 5, 2026 17:18
@marcpopMSFT
marcpopMSFT requested a review from a team as a code owner November 5, 2026 17:18
Copilot AI balanced review requested due to automatic review settings November 5, 2026 17:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the addition of JSON output to dotnet sln list.

No open issues 🎉

What changed in this PR

Adds machine-readable output to the .NET SDK’s dotnet sln list command, addressing the automation scenario in #26303 while preserving the default table display.

Changes:

  • Adds --format <table|json> with sorted JSON path arrays, including [] for empty solutions.
  • Uses source-generated JSON serialization and supports solution filters and solution-folder output.
  • Updates help, localization entries, schema expectations, and command tests.
File Description
test/​dotnet.Tests/​CommandTests/​Solution/​List/​GivenDotnetSlnList.cs Tests formats, empty solutions, folders, filters, and invalid arguments.
test/​dotnet.Tests/​CliSchemaTests.cs Updates the expected schema for --format.
src/​Cli/​Microsoft.DotNet.Cli.Definitions/​xlf/​CommandDefinitionStrings.zh-Hant.xlf Adds the format-help entry for Traditional Chinese localization.
src/​Cli/​Microsoft.DotNet.Cli.Definitions/​xlf/​CommandDefinitionStrings.zh-Hans.xlf Adds the format-help entry for Simplified Chinese localization.
src/​Cli/​Microsoft.DotNet.Cli.Definitions/​xlf/​CommandDefinitionStrings.tr.xlf Adds the format-help entry for Turkish localization.
src/​Cli/​Microsoft.DotNet.Cli.Definitions/​xlf/​CommandDefinitionStrings.ru.xlf Adds the format-help entry for Russian localization.
src/​Cli/​Microsoft.DotNet.Cli.Definitions/​xlf/​CommandDefinitionStrings.pt-BR.xlf Adds the format-help entry for Brazilian Portuguese localization.
src/​Cli/​Microsoft.DotNet.Cli.Definitions/​xlf/​CommandDefinitionStrings.pl.xlf Adds the format-help entry for Polish localization.
src/​Cli/​Microsoft.DotNet.Cli.Definitions/​xlf/​CommandDefinitionStrings.ko.xlf Adds the format-help entry for Korean localization.
src/​Cli/​Microsoft.DotNet.Cli.Definitions/​xlf/​CommandDefinitionStrings.ja.xlf Adds the format-help entry for Japanese localization.
src/​Cli/​Microsoft.DotNet.Cli.Definitions/​xlf/​CommandDefinitionStrings.it.xlf Adds the format-help entry for Italian localization.
src/​Cli/​Microsoft.DotNet.Cli.Definitions/​xlf/​CommandDefinitionStrings.fr.xlf Adds the format-help entry for French localization.
src/​Cli/​Microsoft.DotNet.Cli.Definitions/​xlf/​CommandDefinitionStrings.es.xlf Adds the format-help entry for Spanish localization.
src/​Cli/​Microsoft.DotNet.Cli.Definitions/​xlf/​CommandDefinitionStrings.de.xlf Adds the format-help entry for German localization.
src/​Cli/​Microsoft.DotNet.Cli.Definitions/​xlf/​CommandDefinitionStrings.cs.xlf Adds the format-help entry for Czech localization.
src/​Cli/​Microsoft.DotNet.Cli.Definitions/​Commands/​Solution/​SolutionListCommandDefinition.cs Registers format choices and the table default.
src/​Cli/​Microsoft.DotNet.Cli.Definitions/​CommandDefinitionStrings.resx Defines the format option’s help text.
src/​Cli/​dotnet/​Commands/​Solution/​List/​SolutionListCommand.cs Emits sorted JSON arrays using source-generated serialization.

Review effort: Balanced

@nagilson nagilson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@marcpopMSFT
marcpopMSFT merged commit bc13611 into main Nov 5, 2026
23 checks passed
@marcpopMSFT
marcpopMSFT deleted the copilot/implement-format-option-for-sln-list branch November 5, 2026 23:10
@marcpopMSFT

Copy link
Copy Markdown
Member

/backport to release/11.0.2xx

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0.2xx (link to workflow run)

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@marcpopMSFT backporting to release/11.0.2xx failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Creating an empty commit: Initial plan
Applying: Add table and JSON output formats to dotnet sln list
Using index info to reconstruct a base tree...
M	src/Cli/Microsoft.DotNet.Cli.Definitions/CommandDefinitionStrings.resx
M	src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.cs.xlf
M	src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.de.xlf
M	src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.es.xlf
M	src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.fr.xlf
M	src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.it.xlf
M	src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.ja.xlf
M	src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.ko.xlf
M	src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.pl.xlf
M	src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.pt-BR.xlf
M	src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.ru.xlf
M	src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.tr.xlf
M	src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.zh-Hans.xlf
M	src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.zh-Hant.xlf
M	test/dotnet.Tests/CommandTests/Solution/List/GivenDotnetSlnList.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Cli/Microsoft.DotNet.Cli.Definitions/CommandDefinitionStrings.resx
Auto-merging src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.cs.xlf
Auto-merging src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.de.xlf
Auto-merging src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.es.xlf
Auto-merging src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.fr.xlf
Auto-merging src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.it.xlf
Auto-merging src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.ja.xlf
Auto-merging src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.ko.xlf
Auto-merging src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.pl.xlf
Auto-merging src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.pt-BR.xlf
Auto-merging src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.ru.xlf
Auto-merging src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.tr.xlf
Auto-merging src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.zh-Hans.xlf
Auto-merging src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.zh-Hant.xlf
Auto-merging test/dotnet.Tests/CommandTests/Solution/List/GivenDotnetSlnList.cs
CONFLICT (content): Merge conflict in test/dotnet.Tests/CommandTests/Solution/List/GivenDotnetSlnList.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0002 Add table and JSON output formats to dotnet sln list
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 725f9cac Deployed Nov 5, 2026 by marcpopMSFT via pat_pool #12264
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement bare output for dotnet sln list

4 participants