在控制台或文件中写入 Xamarin 版本信息
目前,要获取 Xamarin 版本信息,我们需要执行以下操作:Xamarin 工作室Xamarin Studio > 关于 Xamarin Studio > 显示详细信息 > 复制信息 [按钮]
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?
谢谢.
获取 Visual Studio for Mac 版本:
To get Visual Studio for Mac version:
/usr/libexec/PlistBuddy -c 'print :CFBundleVersion' /Applications/Visual\ Studio.app/Contents/Info.plist
获取当前使用的 Mono 版本:
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
类似于 Xamarin.iOS 和 Xamarin.Android 框架:
Similar for Xamarin.iOS and Xamarin.Android frameworks:
la /Library/Frameworks/Xamarin.Android.framework/Versions/Current
la /Library/Frameworks/Xamarin.iOS.framework/Versions/Current
如果您只想要 la
命令的版本,您可以使用 | 对命令进行后缀.sed 's/^.*->//g'
.这将替换 ->
之前的所有内容,包括该箭头,因此它只会显示版本号.所以像:
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'
会给 11.4.0.93
.
对于 Mono.framework 来说,它是一个绝对路径,因此您可以再次通过管道传递到 sed 's!.*/!!'
以获取文件名":
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!.*/!!'
将所有这些添加到脚本中:
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
记得在 .sh
文件上运行 chmod +x
.然后你可以用 sh version.sh
运行它,它会吐出来:
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