public async Task <bool> Run() { var adb = new AdbRunner(context); AndroidDeviceInfo?info = await adb.GetDeviceInfo(); if (info == null) { Log.FatalLine("Failed to obtain Android device info"); return(false); } adi = info; Log.InfoLine($"Device: {adi.Model}"); Log.InfoLine($"Device architecture: {adi.Architecture}"); Log.InfoLine($"Device SDK: {adi.SdkVersion}"); if (!await adb.SetPropertyValue("debug.mono.log", "default,timing=bare")) { Log.FatalLine("Failed to set Mono debugging properties"); return(false); } if (!await adb.SetLogcatBufferSize("16M")) { Log.WarningLine("Failed to set logcat buffer size"); } Utilities.CreateDirectory(FullDataDirectoryPath); foreach (RunDefinition run in runs) { if (run.RunPerformanceTest) { if (!await RunPerformanceTest(run, adb)) { return(false); } } } foreach (RunDefinition run in runs) { if (run.RunManagedProfiler) { if (!await RunManagedProfiler(run)) { return(false); } } } foreach (RunDefinition run in runs) { if (run.RunNativeProfiler) { if (!await RunNativeProfiler(run)) { return(false); } } } RawResults.Save(adi, this); return(true); }
async Task <(bool, BuildInfo?)> BuildAndInstall(RunDefinition run) { if (projectUsesGit && projectGitCommit == null) { (projectGitCommit, projectGitBranch) = await GetCommitHashAndBranch(FullProjectDirPath); } string buildCommand = run.BuildCommand; bool usesDotnet = String.Compare("dotnet", Path.GetFileName(buildCommand), StringComparison.OrdinalIgnoreCase) == 0; var args = new List <string> { $"-v:quiet" }; args.AddRange(run.Args); string projectPath = Path.GetRelativePath(FullProjectDirPath, FullProjectFilePath); string binlogBasePath = String.Empty; MSBuildCommon builder; BuildInfo buildInfo; if (!usesDotnet) { var msbuild = ConfigureRunner(new MSBuildRunner(context, buildCommand)); binlogBasePath = GetBinlogBasePath("restore"); if (!await msbuild.Run(projectPath, binlogBasePath, "Restore", configuration, args)) { return(false, null); } binlogBasePath = GetBinlogBasePath("build"); run.BinlogPath = GetRelativeBinlogPath(binlogBasePath); if (!await msbuild.Run(projectPath, binlogBasePath, "SignAndroidPackage", configuration, args)) { return(false, null); } buildInfo = FindFirstAndroidBuildInfo(await msbuild.GetBuildInfo(binlogBasePath)); await Uninstall(buildInfo); binlogBasePath = GetBinlogBasePath("install"); if (!await msbuild.Run(projectPath, binlogBasePath, "Install", configuration, args)) { return(false, null); } builder = msbuild; } else { var dotnet = ConfigureRunner(new DotnetRunner(context, buildCommand)); binlogBasePath = GetBinlogBasePath("build"); run.BinlogPath = GetRelativeBinlogPath(binlogBasePath); if (!await dotnet.Build(projectPath, binlogBasePath, configuration, args)) { return(false, null); } buildInfo = FindFirstAndroidBuildInfo(await dotnet.GetBuildInfo(binlogBasePath)); await Uninstall(buildInfo); binlogBasePath = GetBinlogBasePath("install"); if (!await dotnet.Install(projectPath, binlogBasePath, buildInfo.TargetFramework, configuration, args)) { return(false, null); } builder = dotnet; } if (xaVersionNotDetectedYet) { const string NotGit = "not a git build"; Log.InfoLine("Retrieving Xamarin.Android version information"); xaVersion = await GetXAVersion(builder, binlogBasePath); Log.InfoLine($" Location: {xaVersion.RootDir}"); Log.InfoLine($" Version: {xaVersion.Version}"); string hash = String.IsNullOrEmpty(xaVersion.Commit) ? NotGit : xaVersion.Commit; string branch = String.IsNullOrEmpty(xaVersion.Commit) ? NotGit : xaVersion.Branch; Log.InfoLine($" Git branch: {branch}"); Log.InfoLine($" Git commit: {hash}"); xaVersionNotDetectedYet = false; } return(true, buildInfo); async Task <bool> Uninstall(BuildInfo buildInfo) { (string packageName, _) = GetPackageAndMainActivityNames(buildInfo, run); var adb = new AdbRunner(context); return(await adb.Uninstall(packageName)); } T ConfigureRunner <T> (T runner) where T : MSBuildCommon { runner.WorkingDirectory = FullProjectDirPath; runner.EchoStandardOutput = true; runner.EchoStandardError = true; return(runner); } string GetBinlogBasePath(string phase) { return(GetLogBasePath(Constants.MSBuildLogDir, phase, run.LogTag, projectGitCommit, projectGitBranch)); } string GetRelativeBinlogPath(string binlogBasePath) { return(Path.GetRelativePath(FullDataDirectoryPath, $"{binlogBasePath}.binlog")); } }