diff --git a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/KillProcess.cs b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/KillProcess.cs index 6e800aebed9..e6d51bd2200 100644 --- a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/KillProcess.cs +++ b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/KillProcess.cs @@ -19,7 +19,8 @@ public override bool Execute() Log.LogMessage(MessageImportance.Low, $" {nameof (ProcessId)}: {ProcessId}"); using (var p = Process.GetProcessById (ProcessId)) { - p.Kill (); + if (!p.HasExited) + p.Kill (); } return !Log.HasLoggedErrors; diff --git a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/StartAndroidEmulator.cs b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/StartAndroidEmulator.cs index 6cebd4d2cbc..18fd79b80f7 100644 --- a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/StartAndroidEmulator.cs +++ b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/StartAndroidEmulator.cs @@ -33,6 +33,7 @@ public class StartAndroidEmulator : Task public string Arguments {get; set;} public string ToolPath {get; set;} public string ToolExe {get; set;} + public string LogcatFile {get; set;} public override bool Execute () { @@ -68,7 +69,7 @@ void Run (string emulator) return; var port = string.IsNullOrEmpty (Port) ? "" : $" -port {Port}"; - var arguments = $"{Arguments ?? string.Empty} -verbose -no-boot-anim -no-audio -no-snapshot -cache-size 512 -timezone \"Etc/UTC\" -avd {ImageName}{port}"; + var arguments = $"{Arguments ?? string.Empty} -verbose -logcat-output \"{LogcatFile}\" -no-boot-anim -no-audio -no-snapshot -cache-size 512 -timezone \"Etc/UTC\" -avd {ImageName}{port}"; Log.LogMessage (MessageImportance.Low, $"Tool {emulator} execution started with arguments: {arguments}"); var psi = new ProcessStartInfo () { FileName = emulator, diff --git a/build-tools/scripts/TestApks.targets b/build-tools/scripts/TestApks.targets index 0684f487c44..4e5e09c05d5 100644 --- a/build-tools/scripts/TestApks.targets +++ b/build-tools/scripts/TestApks.targets @@ -26,6 +26,7 @@ 5 $([MSBuild]::Multiply($(AvdLaunchTimeoutMinutes), 60)) $([MSBuild]::Multiply($(AvdLaunchTimeoutSeconds), 1000)) + <_LogcatFilename>$(MSBuildThisFileDirectory)..\..\bin\Test$(Configuration)\logcat-$(Configuration)-full.log @@ -68,6 +69,7 @@ AvdManagerHome="$(AvdManagerHome)" Arguments="$(TestEmulatorArguments)" ImageName="$(TestAvdName)" + LogcatFile="$(_LogcatFilename)" Port="$(_AdbEmulatorPort)" ToolExe="$(EmulatorToolExe)" ToolPath="$(EmulatorToolPath)"> diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs index b4e41cc4d60..fb14f67d0c3 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs @@ -104,7 +104,7 @@ public static void RestartDevice (string project) TestContext.Out.WriteLine ($"Trying to restart Emulator"); // shell out to msbuild and start the emulator again using (var builder = new Builder ()) { - var out1 = RunProcessWithExitCode (builder.BuildTool, $"{project} /restore /t:AcquireAndroidTarget", timeoutInSeconds: 120); + var out1 = RunProcessWithExitCode (builder.BuildTool, $"{(Builder.UseDotNet ? "build" : "")} {project} /restore /t:AcquireAndroidTarget", timeoutInSeconds: 120); TestContext.Out.WriteLine ($"{out1}"); } }