dotnet-install should return structured (xml, json) output
See original GitHub issueSteps to reproduce
the following PS-Call
.\dotnet-install.ps1 -Version latest -Channel master -DryRun
returns:
dotnet-install: Payload URLs:
dotnet-install: - https://dotnetcli.azureedge.net/dotnet/Sdk/2.0.0-preview1-005807/dotnet-dev-win-x64.2.0.0-preview1-005807.zip
dotnet-install: Repeatable invocation: .\dotnet-install.ps1 -Version 2.0.0-preview1-005807 -Channel master -Architecture x64 -InstallDir <auto>
Actual behavior
dotnet-install “calculates” the latest available version.
in this case “2.0.0-preview1-005807” is returned for “latest”
the output is readable for humans but not for programs…
intent: dotnet-install currently seems to be the only “official” API do read data from the “dotnet deployment system”
Expected behavior
for automation purposes we need a mechanism to return the output in a better structured/formatted way like Xml, Json, Hashtable, at least without any comments and surrounding text.
.\dotnet-install.ps1 -Version latest -Channel master -DryRun -ReturnAsHashtable
can return:
@{
SpecificVersion = ''2.0.0-preview1-005807"
Channel = "master"
Architecture = "x64"
InstallDir = "<auto>"
}
i’m specially interested on the value for “SpecificVersion” because it is calculated inside “dotnet-install” ! alternative idea: reorganize the script so that it can be dot sourced AND the functions inside are public available/documented
regards Werner Mairl
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
a) i understand your points b) i have a workaround for now (parsing the output), and i see some option for me (including a refactoring of “dotnet-install.ps1” into a reusable module for this purpose…
c) feel free to close this issue
thank you all!
Werner
@WernerMairl
If this script can print a json to console. It is still not reliable since the down stream console app need to parse and “look for” the json. In this case, it will not be easier or more reliable than parse current format by awk. The “right way” might be .\dotnet-install.ps1 -Version latest -Channel master -DryRun -ReturnAsHashtable -OutputRepeatableInvocation:json and only RepeatableInvocation is printed. However, this will require a lot work. And I don’t think this issue have enough attraction yet to gain a high probity.
Could you try to pipe to awk or similar console app for now?