From 52f3980de6131af1e0080e5ebbca8676fbafe811 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Fri, 6 Sep 2019 09:07:34 -0500 Subject: [PATCH] [build] cleanup MSBuild settings for faster builds (#7381) Context: https://devblogs.microsoft.com/xamarin/optimize-xamarin-android-builds/ The goal here is to improve the developer loop on Android when working on Xamarin.Forms using a few settings for `Debug` builds: * Enable Fast Deployment * `AndroidLinkMode=None` * `DebugType=portable` * `ProduceReferenceAssembly=True` in netstandard projects After these changes changes: Before: Time Elapsed 00:00:37.15 After: Time Elapsed 00:00:15.79 This was just running: msbuild Xamarin.Forms.ControlGallery.Android\Xamarin.Forms.ControlGallery.Android.csproj I was using VS 2019 16.2 on Windows, changing a XAML file. So one thing to note is that `AndroidLinkMode=Full` was used the UITests running on CI are using `Debug` builds. I used a `Condition` to check the `$(CI)` variable, so UITests will be unaffected. Other cleanup: * Explicitly set both `AndroidUseSharedRuntime` and `EmbedAssembliesIntoApk` * `AndroidSupportedAbis` only needs to be specified for `Release` builds. `Debug` builds will detect the attached device/emulator and use the appropriate ABI. * `JavaMaximumHeapSize` can be removed, it defaults to `1G`. * Removed other weird/old/empty MSBuild properties. Rely on `Directory.Build.props`: * `DebugType` is already defined, so we can remove these. * `ProduceReferenceAssembly` can be set if `UsingMicrosoftNETSdk=True`, I could not check `TargetFramework` at this stage, evaluation, since it was blank. This sets the value for all netstandard/SDK-style projects. ~~ [ControlGallery] assembly-level [Preserve] ~~ Context: https://github.com/xamarin/Xamarin.Forms/blob/d7a9c85774502b98460fc740068e264f332bfd82/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla25234.cs#L13 There was also some concern where needing `[Preserve]` attributes would only be found when the CI is running. You don't want to wait 3+ hours to know if you made a small mistake. This adds `[assembly:Preserve]` to the ControlGallery project, so this should be less likely to occur in the future. --- Directory.Build.props | 1 + .../PagesGallery.Droid/PagesGallery.Droid.csproj | 11 +++----- .../Xamarin.Forms.ControlGallery.Android.csproj | 31 +++++++--------------- Xamarin.Forms.Controls/Properties/AssemblyInfo.cs | 2 ++ .../Xamarin.Forms.Controls.csproj | 3 --- 5 files changed, 16 insertions(+), 32 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 914b659..e5996ab 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,6 +12,7 @@ Microsoft Xamarin.Forms 7.3 + True diff --git a/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj b/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj index 54c59ab..37c4b8a 100644 --- a/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj +++ b/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj @@ -18,36 +18,31 @@ Properties\AndroidManifest.xml v9.0 $(AndroidTargetFrameworkVersion) - armeabi-v7a,x86 - - - - True - 1G true - portable false bin\Debug\ DEBUG;TRACE prompt 4 True + False None - portable true bin\Release\ TRACE prompt 4 False + True SdkOnly + armeabi-v7a,x86 diff --git a/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj b/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj index 3640adb..25ee151 100644 --- a/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj +++ b/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj @@ -18,18 +18,10 @@ v9.0 $(AndroidTargetFrameworkVersion) Properties\AndroidManifest.xml - armeabi-v7a,x86 - - - ..\ true - - - 1G - False true @@ -42,39 +34,36 @@ true - full false bin\Debug\ TRACE;DEBUG;HAVE_OPENTK prompt 4 - Full - 1G - True - armeabi-v7a;x86 + None + True + False Xamarin True - - true - pdbonly true bin\Release\ TRACE;HAVE_OPENTK prompt 4 SdkOnly - 1G + False True armeabi-v7a,x86 - - - - true + + Full + False + True + armeabi-v7a,x86 + diff --git a/Xamarin.Forms.Controls/Properties/AssemblyInfo.cs b/Xamarin.Forms.Controls/Properties/AssemblyInfo.cs index 491b8da..866103c 100644 --- a/Xamarin.Forms.Controls/Properties/AssemblyInfo.cs +++ b/Xamarin.Forms.Controls/Properties/AssemblyInfo.cs @@ -1,8 +1,10 @@ using System.Runtime.CompilerServices; using Xamarin.Forms; +using Xamarin.Forms.Internals; [assembly: InternalsVisibleTo ("Xamarin.Forms.ControlGallery.Android")] [assembly: XmlnsDefinition("http://xamarin.com/schemas/2014/forms/customurl1", "Xamarin.Forms.Controls.CustomNamespace1")] [assembly: XmlnsDefinition("http://xamarin.com/schemas/2014/forms/customurl1", "Xamarin.Forms.Controls.CustomNamespace2")] [assembly: XmlnsDefinition("http://xamarin.com/schemas/2014/forms/customurl2", "Xamarin.Forms.Controls.CustomNamespace3")] +[assembly: Preserve] \ No newline at end of file diff --git a/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj b/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj index 5618146..5e81105 100644 --- a/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj +++ b/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj @@ -1,8 +1,6 @@  netstandard2.0 - - True @@ -10,7 +8,6 @@ prompt 4 0114;0108;0109;4014;0649;0169;0472;0414;0168;0219;0429 - full TRACE;APP -- 2.7.4