Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,48 @@ properties that determine build ordering.
</_PrepareBuildApkDependsOnTargets>
</PropertyGroup>

<PropertyGroup>
<InstallDependsOnTargets>
SignAndroidPackage;
_DeployApk;
_DeployAppBundle;
</InstallDependsOnTargets>
<UninstallDependsOnTargets>
AndroidPrepareForBuild;
_Uninstall
</UninstallDependsOnTargets>
<!-- When inside an IDE, Build has just been run. This is a minimal list of targets for SignAndroidPackage. -->
<_MinimalSignAndroidPackageDependsOn>
BuildOnlySettings;
_CreatePropertiesCache;
ResolveReferences;
PrepareResources;
CreateSatelliteAssemblies;
_CopyPackage;
_Sign;
_CreateUniversalApkFromBundle;
</_MinimalSignAndroidPackageDependsOn>
<SignAndroidPackageDependsOn Condition=" '$(BuildingInsideVisualStudio)' != 'true' ">
Build;
Package;
_Sign;
_CreateUniversalApkFromBundle;
</SignAndroidPackageDependsOn>
<SignAndroidPackageDependsOn Condition=" '$(BuildingInsideVisualStudio)' == 'true' ">
$(_MinimalSignAndroidPackageDependsOn);
</SignAndroidPackageDependsOn>
<!-- This should function similar to SignAndroidPackage inside VS plus also deploy -->
<DeployToDeviceDependsOnTargets Condition=" '$(_XASupportsFastDev)' == 'true' ">
$(_MinimalSignAndroidPackageDependsOn);
_Upload;
</DeployToDeviceDependsOnTargets>
<DeployToDeviceDependsOnTargets Condition=" '$(_XASupportsFastDev)' != 'true' ">
$(_MinimalSignAndroidPackageDependsOn);
_DeployApk;
_DeployAppBundle;
</DeployToDeviceDependsOnTargets>
</PropertyGroup>

<PropertyGroup Condition=" '$(AndroidApplication)' != 'True' ">
<BuildDependsOn>
$(_AndroidBuildDependsOn);
Expand Down
32 changes: 1 addition & 31 deletions src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2800,28 +2800,10 @@ because xbuild doesn't support framework reference assemblies.
<UnzipToFolder Sources="$(_UniversalApkSetIntermediate)" DestinationDirectories="$(OutDir)" Files="@(_FilestoExtract)" />
</Target>

<PropertyGroup>
<SignAndroidPackageDependsOn Condition=" '$(BuildingInsideVisualStudio)' != 'True' ">
Build;
Package;
_Sign;
_CreateUniversalApkFromBundle;
</SignAndroidPackageDependsOn>
<!-- When inside an IDE, Build has just been run. This is a minimal list of targets for SignAndroidPackage. -->
<SignAndroidPackageDependsOn Condition=" '$(BuildingInsideVisualStudio)' == 'True' ">
BuildOnlySettings;
_CreatePropertiesCache;
ResolveReferences;
PrepareResources;
CreateSatelliteAssemblies;
_CopyPackage;
_Sign;
_CreateUniversalApkFromBundle;
</SignAndroidPackageDependsOn>
</PropertyGroup>
<Target Name="SignAndroidPackage" DependsOnTargets="$(SignAndroidPackageDependsOn)">
</Target>

<Target Name="DeployToDevice" DependsOnTargets="$(DeployToDeviceDependsOnTargets)" />

<!-- Callable targets -->
<PropertyGroup>
Expand Down Expand Up @@ -2938,18 +2920,6 @@ because xbuild doesn't support framework reference assemblies.
<WriteLinesToFile File="$(_LldbConfigFile)" Lines="MANIFEST=$(IntermediateOutputPath)android\AndroidManifest.xml"/>
</Target>

<PropertyGroup>
<InstallDependsOnTargets>
SignAndroidPackage;
_DeployApk;
_DeployAppBundle;
</InstallDependsOnTargets>
<UninstallDependsOnTargets>
AndroidPrepareForBuild;
_Uninstall
</UninstallDependsOnTargets>
</PropertyGroup>

<Target Name="_DeployApk"
Condition=" '$(AndroidPackageFormat)' != 'aab' ">
<AndroidAdb
Expand Down
25 changes: 25 additions & 0 deletions tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,31 @@ public void DotNetRun (bool isRelease, string typemapImplementation)
Assert.IsTrue (didLaunch, "Activity should have started.");
}

[Test]
[TestCase (true)]
[TestCase (false)]
public void DeployToDevice (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.Build ("DeployToDevice"), "`dotnet build -t:DeployToDevice` should succeed");

// Launch the app using adb
ClearAdbLogcat ();
var result = AdbStartActivity ($"{proj.PackageName}/{proj.JavaPackageName}.MainActivity");
Assert.IsTrue (result.Contains ("Starting: Intent"), $"Activity should have launched. adb output:\n{result}");

bool didLaunch = WaitForActivityToStart (proj.PackageName, "MainActivity",
Path.Combine (Root, builder.ProjectDirectory, "logcat.log"), 30);
Assert.IsTrue (didLaunch, "Activity should have started.");
}

[Test]
public void ActivityAliasRuns ([Values (true, false)] bool isRelease)
{
Expand Down
Loading