Write Xamarin version information in Console or file

Viewed 144

Currently, to get Xamarin version information we need to do the following: Xamarin Studio Xamarin Studio > About Xamarin Studio > Show Details > Copy Information [button]

I need to have these information in a file or writing them in a console. Do we have a command to do this?

Thank you.

1 Answers

To get Visual Studio for Mac version:

/usr/libexec/PlistBuddy -c 'print :CFBundleVersion' /Applications/Visual\ Studio.app/Contents/Info.plist

To get currently used Mono version:

mono --version

or you can look at what current version links to with:

la /Library/Frameworks/Mono.framework/Versions/Current

Similar for Xamarin.iOS and Xamarin.Android frameworks:

la /Library/Frameworks/Xamarin.Android.framework/Versions/Current
la /Library/Frameworks/Xamarin.iOS.framework/Versions/Current

EDIT: If you only want the version from the la commands you can postfix the commands with | sed 's/^.*-> //g'. This will replace everything before the -> including that arrow with nothing, so it will only display the version number. So something like:

la /Library/Frameworks/Xamarin.iOS.framework/Versions/Current | sed 's/^.*-> //g'

Would give 11.4.0.93.

For the Mono.framework one, it is an absolute path, so you can pipe again to sed 's!.*/!!' to just get the "filename":

la /Library/Frameworks/Mono.framework/Versions/Current | sed 's/^.*-> //g' | sed 's!.*/!!'

EDIT:

Add all this to a script:

#!/usr/bin/env bash

mono_version=$(ls -n /Library/Frameworks/Mono.framework/Versions/Current | sed 's/^.*-> //g' | sed 's!.*/!!')
vs_version=$(/usr/libexec/PlistBuddy -c 'print :CFBundleVersion' /Applications/Visual\ Studio.app/Contents/Info.plist)
ios_version=$(ls -n /Library/Frameworks/Xamarin.iOS.framework/Versions/Current | sed 's/^.*-> //g')
android_version=$(ls -n /Library/Frameworks/Xamarin.Android.framework/Versions/Current | sed 's/^.*-> //g')
echo "mono:" $mono_version
echo "vs version:" $vs_version
echo "ios version:" $ios_version
echo "android version:" $android_version

Remember to run chmod +x on the .sh file. Then you can run this with sh version.sh and it will spit out:

mono: 5.4.1
vs version: 7.3.0.708
ios version: 11.4.0.93
android version: 8.1.0-21
Related