diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Application.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Application.targets index 5913bba6b77..8e02ed9df2c 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Application.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Application.targets @@ -15,8 +15,6 @@ This file contains targets specific for Android application projects. false <_RuntimeIdentifierUsesAppHost>false - dotnet - build "$(MSBuildProjectFullPath)" -target:Run --configuration "$(Configuration)" <_RunDependsOn Condition=" '$(_XASupportsFastDev)' == 'true' "> @@ -27,8 +25,29 @@ This file contains targets specific for Android application projects. Install; StartAndroidActivity; + <_AndroidComputeRunArgumentsDependsOn> + Install; + + + + + + + $(AdbToolExe) + adb.exe + adb + $([System.IO.Path]::Combine ('$(AdbToolPath)', '$(RunCommand)')) + $(AdbTarget) shell am start -S -n "$(_AndroidPackage)/$(AndroidLaunchActivity)" + $(MSBuildProjectDirectory) + + + diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs index 6579abe21aa..6ac736b3fbc 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs @@ -28,6 +28,24 @@ public void Teardown () proj = null; } + [Test] + public void DotNetRun ([Values (true, false)] bool isRelease) + { + var proj = new XamarinAndroidApplicationProject { + IsRelease = isRelease + }; + using var builder = CreateApkBuilder (); + builder.Save (proj); + + var dotnet = new DotNetCLI (Path.Combine (Root, builder.ProjectDirectory, proj.ProjectFilePath)); + Assert.IsTrue (dotnet.Build (), "`dotnet build` should succeed"); + Assert.IsTrue (dotnet.Run (), "`dotnet run --no-build` should succeed"); + + bool didLaunch = WaitForActivityToStart (proj.PackageName, "MainActivity", + Path.Combine (Root, builder.ProjectDirectory, "logcat.log"), 30); + Assert.IsTrue (didLaunch, "Activity should have started."); + } + [Test] public void NativeAssemblyCacheWithSatelliteAssemblies ([Values (true, false)] bool enableMarshalMethods) {