我想在Xamarin应用程序的构建作业期间检索Visual Studio for Mac的版本信息。目的是将它们作为调试信息包含在二进制文件中。是否可以通过编程或使用msbuild的命令语句获取Visual Studio,Xamarin.iOS和Xamarin.Android的版本号?
手动可以获得以下信息:
Visual Studio > About Visual Studio > Show Details > Copy Information [button]
=== Visual Studio Community 2017 for Mac ===
Version 7.6.11 (build 9)
Installation UUID: f7e73512-ad50-4119-a682-e2cf05031ad6
Runtime:
Mono 5.12.0.309 (2018-02/39d89a335c8) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)
Package version: 512000309
=== NuGet ===
Version: 4.3.1.4445
=== .NET Core ===
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.1.2
2.1.1
2.0.5
2.0.4
SDK: /usr/local/share/dotnet/sdk/2.1.302/Sdks
SDK Versions:
2.1.302
2.1.301
2.1.4
2.1.3
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.12.0/lib/mono/msbuild/15.0/bin/Sdks
=== Xamarin.Profiler ===
Version: 1.6.3
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Xamarin.Android ===
Version: 9.0.0.20 (Visual Studio Community)
Android SDK: /Users/christopher/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.4 (API level 19)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
7.0 (API level 24)
7.1 (API level 25)
8.0 (API level 26)
8.1 (API level 27)
SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.1
SDK Build Tools Version: 27.0.3
Java SDK: /usr
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
=== Apple Developer Tools ===
Xcode 10.1 (14460.46)
Build 10B61
=== Xamarin.Mac ===
Version: 5.0.0.0 (Visual Studio Community)
Hash: b40230c0
Branch:
Build date: 2018-09-27 11:41:37-0400
=== Xamarin.iOS ===
Version: 12.2.1.10 (Visual Studio Community)
Hash: f2a05edd
Branch: d15-9
Build date: 2018-10-31 18:55:57-0400
=== Xamarin Inspector ===
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1
=== Build Information ===
Release ID: 706110009
Git revision: d7cd66f5e3acd3d46ba0b94a0c935378f828bde0
Build date: 2018-10-31 17:17:12+00
Build branch: release-7.6
Xamarin extensions: bc9b985bfcb480b04a208a6d4045adc443a07857
=== Operating System ===
Mac OS X 10.13.6
Darwin 17.7.0 Darwin Kernel Version 17.7.0
Thu Jun 21 22:53:14 PDT 2018
root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64
答案 0 :(得分:3)
这是我的Global.cs
之一的简化版本,其中包含在构建过程中获得的版本信息:
namespace SomeVersionInfo
{
public static class Globals
{
public const string VS4MVersion = "SushiVS4MVersion";
public const string XiOSVersion = "SushiXiOSVersion";
public const string XDroidVersion = "SushiXDroidVersion";
}
}
VS4MVersion=`/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' /Applications/Visual\ Studio\ \(Preview\).app/Contents/Info.plist`
XDroidVersion=$(< /Library/Frameworks/Xamarin.Android.framework/Versions/Current/version)
XiOSVersion=$(< /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/Version)
sed -e 's/SushiVS4MVersion/'"$VS4MVersion"'/g' Global.template > Global.cs
sed -i '' -e "s/SushiXiOSVersion/$XiOSVersion/g" Global.cs
sed -i '' -e "s/SushiXDroidVersion/$XDroidVersion/g" Global.cs
namespace SomeVersionInfo
{
public static class Globals
{
public const string VS4MVersion = "8.0.0.869";
public const string XDroidVersion = "9.1.5";
public const string XiOSVersion = "12.2.1.13";
}
}
答案 1 :(得分:0)
其他一些版本信息可以通过以下方式检索:
VisualStudio=`/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' /Applications/Visual\ Studio.app/Contents/Info.plist`
echo $VisualStudio
NetCoreSdk=`dotnet --version`
echo $NetCoreSdk
MsBuild=`msbuild /version | sed -n 4p`
echo $MsBuild
XamarinProfiler=`/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' /Applications/Xamarin\ Profiler.app/Contents/Info.plist`
echo $XamarinProfiler
XDroid=$(< /Library/Frameworks/Xamarin.Android.framework/Versions/Current/version)
echo $XDroid
SdkTools=`cat /Users/christopher/Library/Developer/Xamarin/android-sdk-macosx/tools/source.properties | grep Pkg.Revision | tail -c 7`
echo $SdkTools
SdkPlatformTools=`cat ~/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/source.properties | grep Pkg.Revision | tail -c 7`
echo $SdkPlatformTools
SdkBuildTools=`ls ~/Library/Developer/Xamarin/android-sdk-macosx/build-tools | tail -n 1`
echo $SdkBuildTools
Java=`java -version 2>&1 | awk -F '"' '/version/ {print $2}'`
echo $Java
AppleDeveloperTools=`/usr/bin/xcodebuild -version | head -1 | sed -n -e 's/^.*Xcode //p'`
echo $AppleDeveloperTools
XMac=$(< /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version)
echo $XMac
XiOS=$(< /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/Version)
echo $XiOS
MacOSX=`sw_vers -productVersion`
echo $MacOSX
Visual Studio for Mac似乎使用了自己的NuGet版本,因为nuget help
打印的版本与Visual Studio版本信息中列出的版本不同。在我们的构建工作中,我们下载最新的nuget.exe并使用它来还原解决方案。因此,我们获取nuget.exe的版本:
NuGet=`echo $(mono nuget.exe help | head -1) | sed -n -e 's/^.*Version: //p'`