From bc1a818abda07a6e05618b34bd245f1cb6c0cb80 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Mon, 20 Aug 2018 14:14:22 -0500 Subject: [PATCH 1/3] [build] option for Java.Interop to be built as non-PCL Fixes: http://work.devdiv.io/667174 When building a "Hello World" Xamarin.Android app, I noticed the following in the build log: Adding assembly reference for Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065, recursively... Adding assembly reference for System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.ComponentModel.Composition, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, recursively... Adding assembly reference for System.Diagnostics.Debug, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Threading, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Collections, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Collections.Concurrent, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Reflection, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Reflection.Primitives, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Dynamic.Runtime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.ObjectModel, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Linq, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Runtime.InteropServices, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Runtime.Extensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Reflection.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065, recursively... It appears that Java.Interop is a PCL, and we end up having to work with lots of facade assemblies during our build! My thought is that we should build `Java.Interop.dll` the same as `Mono.Android.dll`: true $(XAInstallPrefix)xbuild-frameworks\MonoAndroid\v1.0\mscorlib.dll False $(XAInstallPrefix)xbuild-frameworks\MonoAndroid\v1.0\System.dll False $(XAInstallPrefix)xbuild-frameworks\MonoAndroid\v1.0\System.Core.dll False I added a new property, `$(JavaInteropProfile)` we can set downstream in Xamarin.Android. We can set this with a `Configuration.Override.props` file that is already used in Xamarin.Android's build process. After doing this, the log now reads: Adding assembly reference for Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065, recursively... Adding assembly reference for Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065, recursively... And the savings in build times for "Hello World", this is the `Rebuild` target: - `Debug` + PCL - 8.424s - `Release` + PCL - 13.651s - `Debug` + *not* PCL - 4.258s - `Release` + *not PCL - 9.487s That does bring up a big question, however... Why are facade assemblies adding so much build time??? This change is good: making `Java.Interop` have fewer dependencies. But I suspect there is more work to be done downstream in Xamarin.Android. I have a feeling referencing `netstandard` libraries cause the same problem to occur. --- src/Java.Interop/Java.Interop.Net45.props | 20 ++++++++++++++++++++ src/Java.Interop/Java.Interop.PCL.props | 6 ++++++ src/Java.Interop/Java.Interop.csproj | 6 ++++-- src/Java.Interop/Java.Interop.targets | 1 - 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 src/Java.Interop/Java.Interop.Net45.props create mode 100644 src/Java.Interop/Java.Interop.PCL.props diff --git a/src/Java.Interop/Java.Interop.Net45.props b/src/Java.Interop/Java.Interop.Net45.props new file mode 100644 index 000000000..4edf08833 --- /dev/null +++ b/src/Java.Interop/Java.Interop.Net45.props @@ -0,0 +1,20 @@ + + + + true + + + + $(XAInstallPrefix)xbuild-frameworks\MonoAndroid\v1.0\mscorlib.dll + False + + + $(XAInstallPrefix)xbuild-frameworks\MonoAndroid\v1.0\System.dll + False + + + $(XAInstallPrefix)xbuild-frameworks\MonoAndroid\v1.0\System.Core.dll + False + + + diff --git a/src/Java.Interop/Java.Interop.PCL.props b/src/Java.Interop/Java.Interop.PCL.props new file mode 100644 index 000000000..53651a256 --- /dev/null +++ b/src/Java.Interop/Java.Interop.PCL.props @@ -0,0 +1,6 @@ + + + Profile111 + + + diff --git a/src/Java.Interop/Java.Interop.csproj b/src/Java.Interop/Java.Interop.csproj index 1a1fb389b..4aa7e1dd3 100644 --- a/src/Java.Interop/Java.Interop.csproj +++ b/src/Java.Interop/Java.Interop.csproj @@ -10,7 +10,6 @@ Library Java.Interop Java.Interop - Profile111 v4.5 1591 true @@ -129,7 +128,10 @@ - + + + + diff --git a/src/Java.Interop/Java.Interop.targets b/src/Java.Interop/Java.Interop.targets index e8d31b32c..26a56515e 100644 --- a/src/Java.Interop/Java.Interop.targets +++ b/src/Java.Interop/Java.Interop.targets @@ -3,7 +3,6 @@ mono - From ba8ac409b5813ef33a07c43bfa08ba1ee3e88af1 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Fri, 24 Aug 2018 15:16:02 -0500 Subject: [PATCH 2/3] [build] $(JavaInteropProfile) now outputs to $(Configuration)Net45 folder This allows us to have two sets of outputs: - bin/Debug/Java.Interop.dll - referenced by MSBuild tasks - bin/DebugNet45/Java.Interop.dll - referenced by Mono.Android.dll and apps Other changes: - Fixed warning where file was getting imported twice - Updated `.gitignore` for `*.binlog` files --- .gitignore | 3 ++- src/Java.Interop/Java.Interop.Net45.props | 10 ++++++++-- src/Java.Interop/Java.Interop.csproj | 1 - 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index b4dd41db9..6ba8cb937 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ packages .nuget/ *.userprefs *.user -Resource.designer.cs \ No newline at end of file +Resource.designer.cs +*.binlog \ No newline at end of file diff --git a/src/Java.Interop/Java.Interop.Net45.props b/src/Java.Interop/Java.Interop.Net45.props index 4edf08833..483ad8f3f 100644 --- a/src/Java.Interop/Java.Interop.Net45.props +++ b/src/Java.Interop/Java.Interop.Net45.props @@ -1,8 +1,9 @@ - - true + true + ..\..\bin\$(Configuration)Net45 + $(XAInstallPrefix)xbuild-frameworks\MonoAndroid\v1.0\mscorlib.dll @@ -17,4 +18,9 @@ False + + + + + diff --git a/src/Java.Interop/Java.Interop.csproj b/src/Java.Interop/Java.Interop.csproj index 4aa7e1dd3..9feb34956 100644 --- a/src/Java.Interop/Java.Interop.csproj +++ b/src/Java.Interop/Java.Interop.csproj @@ -129,7 +129,6 @@ - From 399a58c176ad606b46987f5efac30eb62716428a Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Fri, 24 Aug 2018 15:23:06 -0500 Subject: [PATCH 3/3] Whoops doc XML file was missing --- src/Java.Interop/Java.Interop.Net45.props | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Java.Interop/Java.Interop.Net45.props b/src/Java.Interop/Java.Interop.Net45.props index 483ad8f3f..fb070009c 100644 --- a/src/Java.Interop/Java.Interop.Net45.props +++ b/src/Java.Interop/Java.Interop.Net45.props @@ -2,6 +2,7 @@ true ..\..\bin\$(Configuration)Net45 + $(OutputPath)\Java.Interop.xml