[build] cleanup MSBuild settings for faster builds (#7381)
authorJonathan Peppers <jonathan.peppers@microsoft.com>
Fri, 6 Sep 2019 14:07:34 +0000 (09:07 -0500)
committerRui Marinho <me@ruimarinho.net>
Fri, 6 Sep 2019 14:07:34 +0000 (15:07 +0100)
commit52f3980de6131af1e0080e5ebbca8676fbafe811
tree8641205d7be19d74ee6b29e1fd63daa1e785897c
parent28792573db044929e75340f0ef7e032c8d88ba41
[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
PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj
Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj
Xamarin.Forms.Controls/Properties/AssemblyInfo.cs
Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj