It would be nice if there was a format which just outputted the version and nothing else
Closed this issue · 6 comments
I would like to basically to be able to use the version in other places in my build, but the current output formats require a extra work to get it. It would be nice if there was a output format that could print out the version and nothing else. Is there a recommended way for doing this now?
export VERSION="$(dotnet version -f example.csproj)"
echo "$VERSION" # 1.0.0
Here's a workaround in bash:
dotnet version -f example.csproj --output-format json | tr { '\n' | tr , '\n' | tr } '\n' | grep "currentVersion" | awk -F'"' '{print $4}'
There's the --output-format=json
option but that requires jq
parsing.
Adding a raw
or bare
output format is definitely also possible
Yeah exactly, it would be nice just because parsing the output with jq may not be cross platform consistent.
@justinmchase sorry forgot all about this issue, thanks for pinging me. I totally agree, forcing people to have json parsing tools installed is not great.
Check out this MR: #72 - should address your issue :)
Based on that change the solution will now be:
export VERSION="$(dotnet version -f example.csproj -o bare)"
echo "$VERSION" # 1.0.0
@justinmchase yes, but without the -- those are needed to stop dotnet run
from parsing any further command line arguments. So
export VERSION="$(dotnet version -f example.csproj -o bare)" echo "$VERSION" # 1.0.0
I'll get it merged and released