[workload] Machine readable outputs should only output JSON
See original GitHub issueIs your feature request related to a problem? Please describe.
Commands like dotnet workload update --print-rollback
and dotnet workload list --machine-readable
are very helpful, but they should print only JSON to stdout.
Right now I run dotnet workload list --machine-readable
and this is what gets printed to stdout:
Failed to update the advertising manifest microsoft.net.sdk.tvos: Unable to load the service index for source https://REDACTED/index.json..
Failed to update the advertising manifest microsoft.net.sdk.android: Unable to load the service index for source https://REDACTED/index.json..
Failed to update the advertising manifest microsoft.net.sdk.maui: Unable to load the service index for source https://REDACTED/index.json..
Failed to update the advertising manifest microsoft.net.workload.emscripten: Unable to load the service index for source https://REDACTED/index.json..
Failed to update the advertising manifest microsoft.net.sdk.macos: Unable to load the service index for source https://REDACTED/index.json..
Failed to update the advertising manifest microsoft.net.sdk.maccatalyst: Unable to load the service index for source https://REDACTED/index.json..
Failed to update the advertising manifest microsoft.net.sdk.ios: Unable to load the service index for source https://REDACTED/index.json..
Failed to update the advertising manifest microsoft.net.workload.mono.toolchain: Unable to load the service index for source https://REDACTED/index.json..
==workloadListJsonOutputStart==
{"installed":["macos","ios"],"updateAvailable":[{"existingManifestVersion":"12.0.101-preview.10.249","availableUpdateManifestVersion":"12.0.101-preview.10.251","description":".NET SDK Workload for building macOS applications.","workloadId":"macos"},{"existingManifestVersion":"15.0.101-preview.9.31","availableUpdateManifestVersion":"15.0.101-preview.10.251","description":".NET SDK Workload for building iOS applications.","workloadId":"ios"}]}
==workloadListJsonOutputEnd==
I have to process this and it complicates my tooling.
Describe the solution you’d like
Commands like rg
, lsblk
, losetup
, etc that offer JSON output modes only print JSON to stdout. Everything else goes to stderr. dotnet workload
commands that are intended to offer machine-readable output would be most useful if they functioned similarly.
This opens up much easier shell scripting workflows. In powershell you could pipe to ConvertFrom-Json
without any other ceremony. In other shells you could pipe to jq
.
Additional context
I would imagine this would break compatibility with tools used to the current output, so unfortunately it would require another option, like --really-machine-readable
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Could also just output the manifest errors and other verbose items to stderr instead of stdout.
Summary for anyone that picks this up: