Skip to content
Draft
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 @@ -176,7 +176,6 @@ properties that determine build ordering.
_CheckForDeletedResourceFile;
_ComputeAndroidResourcePaths;
_UpdateAndroidResgen;
_CreateAar;
</_UpdateAndroidResourcesDependsOn>
<CompileDependsOn>
_SetupMSBuildAllProjects;
Expand Down Expand Up @@ -246,6 +245,7 @@ properties that determine build ordering.
<_IncludeAarInNuGetPackageDependsOn>
_BuildAndroidGradleProjects;
_CategorizeAndroidLibraries;
_CreateAar;
</_IncludeAarInNuGetPackageDependsOn>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,29 @@ public void LibraryProjectTargetsDoNotBreak ([Values] AndroidRuntime runtime)
}
}

[Test]
public void CreateAarRunsOnceWithGeneratePackageOnBuild ()
{
// https://github.com/dotnet/android/issues/11514
// `_CreateAar` was being invoked twice for a single library build when
// `GeneratePackageOnBuild=true`: once via `BuildDependsOn`, and again via
// NuGet pack's per-TFM dispatch which entered the project at
// `_GetFrameworkAssemblyReferences`. That target transitively pulled in
// `UpdateAndroidResources` -> `_UpdateAndroidResources` -> `_CreateAar`
// via `_UpdateAndroidResourcesDependsOn`. The second invocation can race
// the first writer when parallel builds (-m) consumers concurrently read
// the .aar via `Files.HashFile`, producing `XARLP7024`.
var proj = new XamarinAndroidLibraryProject ();
proj.SetProperty ("GeneratePackageOnBuild", "true");
using (var b = CreateDllBuilder ()) {
b.Verbosity = LoggerVerbosity.Detailed;
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
int count = b.LastBuildOutput.Count (l => l.Contains ("Target \"_CreateAar\" in file"));
Assert.AreEqual (1, count,
$"`_CreateAar` should only execute once per build of a library project; was {count}.");
}
}

[Test]
public void ManifestMergerIncremental ([Values] AndroidRuntime runtime)
{
Expand Down