Write Xamarin version information in Console or file

巧了我就是萌 提交于 2020-03-22 03:37:30

问题


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:


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


来源:https://stackoverflow.com/questions/47094941/write-xamarin-version-information-in-console-or-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!