From 927108217f08952c9d3e45e2f7f8246217403419 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Fri, 20 Jan 2017 12:18:13 -0500 Subject: [PATCH] [Xamarin.Android.Build.Tasks] _CreateNativeLibraryArchive needs references Context: https://github.com/xamarin/xamarin-android/commit/7343965a0bbee3d192684dbb371789613bf5b830 Context: https://github.com/xamarin/xamarin-android/commit/743529c1cc8188724048755b30ccd7c4f681f5e5 Context: https://gitter.im/Microsoft/msbuild?at=58823bfd074f7be763f6aeaf ...through... https://gitter.im/Microsoft/msbuild?at=5882440d300f220a661148c8 We want to be able to build the xamarin-android repo via `msbuild`, because `msbuild` may be the default build system in the "Cycle 10" timeframe (please oh please oh please...) and because building with `msbuild` is a prerequisite to sanely building on Windows, which would be extremely handy for increasing our contributor base. Unfortunately, [commit 743529c1 didn't fix all problems][0]: error MSB4018: The "CreateNativeLibraryArchive" task failed unexpectedly. error MSB4018: System.IO.FileNotFoundException: ../sqlite-xamarin/src/main/libs/armeabi-v7a/libsqlite3_xamarin.so does not exist ... The MSB4018 is a *symptom*, not a cause. The *cause* of the error is twofold: 1. `Mono.Data.Sqlite.csproj` depends on build artifacts from building the `sqlite-xamarin.mdproj` project. 2. `sqlite-xamarin.mdproj` isn't being built before `Mono.Data.Sqlite.csproj`. (2) is a bit of a head scratcher: `Mono.Data.Sqlite.csproj` has a `@(ProjectReference)` including `sqlite-xamarin.mdproj`; surely that's enough, right? Wrong. `@(ProjectReference)` isn't "special"; it's just an item group, interpreted by the `ResolveReferences` target. The problem we're seeing here is that the `ResolveReferences` target isn't executed before the `_CreateNativeLibraryArchive` target is executed. Consequently `@(ProjectReference)` isn't handled *at all* prior to the `_CreateNativeLibraryArchive` invocation, which is why `sqlite-xamarin.mdproj` isn't built before `Mono.Data.Sqlite.csproj`. (Why's this work on `xbuild`? No idea!) Update the `_CreateNativeLibraryArchive` target to add a `DependsOnTargets` value of `ResolveReferences`. This explicit target references ensures that referenced projects (`sqlite-xamarin.mdproj`) are resolved and built before the current project (`Mono.Data.Sqlite.csproj`), allowing cross-references of build artifacts in a sane(r) fashion. [0]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-msbuild/99/consoleText --- src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index d437a771d94..df2c0897c01 100755 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -1145,6 +1145,7 @@ because xbuild doesn't support framework reference assemblies.