Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slow app build - Xamarin for Visual Studio

Tags:

The build/deploy of my Xamarin.Android app is painfully slow these days. I cannot remember it being this slow before.

I have enabled:

  • Use shared runtime
  • Fast deployment

Enabling or disabling these settings doesn't make any difference. In both scenarios it takes about 2 minutes and 20 seconds (up to over 3 minutes!) to build/deploy my app. Using a real device or the Visual Studio emulator for Android doesn’t make a difference as well.

Why could this be so extremely slow? Am I not using the right settings?

UPDATE 2

Yesterday (november 14th) I updated Xamarin.VS to 4.2.1.58. No improvements in build duration.

We are using TeamCity to build release versions of our app, the TeamCity statistics show perfectly what I'm talking about.

In the graph below, I selected last quarter as the date range. See the major increase in build duration. Now, I don't mind waiting 3 minutes for a release build, but it's not acceptable when debugging.

Nov. 7, before installing latest Xamarin update Nov. 8, after installing update and targetting Android 7

UPDATE 3

Jon, thanks for your help.

In the meantime, I have done some research myself in the build logs and found the duration per build task as well. I found that somehow GetAdditionalResourcesFromAssemblies takes a lot of time.

The amount of resources I have in the app didn't change dramatically, so this got me thinking: could it be another assembly that I'm using..

I then did a checkout of revision 1029 (which was the last revision that took about a minute to build) and tried to debug it in the updated environment. It still built within 1m30s...

So:

  • It's probably not the VS Xamarin update (else revision 1029 would build slow as well)
  • It's probably not fast deployment, the duration increased in the build process

So what was changed between revision 1029 and 1030 of my app?

  1. Updated Xamarin for Visual Studio to 4.2.0.719
  2. Installed Android 7.0 SDK platform in Android SDK Manager
  3. Changed Compile using Android version to Android 7.0 in project properties
  4. Updated Xamarin.Android Support Libraries from 23.4.0.1 to 24.2.1

Change 4 was why I updated in the first place, I wanted to use Bottomsheet, which was improved in version 24. But the support library nugets were targeting Android 7.0, so I had to do 1-3 in order to be able to update the support libraries.

Could something have changed in the Support Library bindings that caused all this? I checked the internet for other devs having this issue, and found this in the Xamarin forum. Setting AndroidExplicitCrunch build property to true seems to fix it there, but when I tried that, I got another build error.

Anyway, that's what I've tried in the meantime. Now, as requested, here is my diagnostic build log:

1>Project Performance Summary:
1>        3 ms  C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAll.App.Shared\OverAll.App.Shared.csproj   3 calls
1>                  1 ms  GetTargetPath                              1 calls
1>                  0 ms  GetNativeManifest                          1 calls
1>                  2 ms  GetCopyToOutputDirectoryItems              1 calls
1>        4 ms  C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAllField.XamarinAndroid.DataLayer\OverAllField.XamarinAndroid.DataLayer.csproj   3 calls
1>                  1 ms  GetTargetPath                              1 calls
1>                  0 ms  GetNativeManifest                          1 calls
1>                  3 ms  GetCopyToOutputDirectoryItems              1 calls
1>    40103 ms  C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAllField.XamarinAndroid.ServiceClient\OverAllField.XamarinAndroid.ServiceClient.csproj   1 calls
1>
1>Target Performance Summary:
1>        0 ms  Compile                                    1 calls
1>        0 ms  ResolveReferences                          1 calls
1>        0 ms  BclBuildGetTargetPath                      1 calls
1>        0 ms  EnsureNuGetPackageBuildImports             1 calls
1>        0 ms  AfterResGen                                1 calls
1>        0 ms  ResolveCodeAnalysisRuleSet                 1 calls
1>        0 ms  _CreatePropertiesCache                     1 calls
1>        0 ms  _SetTargetFrameworkMonikerAttribute        1 calls
1>        0 ms  BeforeResGen                               1 calls
1>        0 ms  ModifyUnitTestPlatformVersion              1 calls
1>        0 ms  CreateCustomManifestResourceNames          1 calls
1>        0 ms  BclBuildAddProjectReferenceProperties      1 calls
1>        0 ms  _ResolveMonoAndroidFramework               1 calls
1>        0 ms  UpdateAndroidResources                     1 calls
1>        0 ms  CoreBuild                                  1 calls
1>        0 ms  ExpressionBuildExtension                   1 calls
1>        0 ms  _CheckTargetFramework                      1 calls
1>        0 ms  _CopyAppConfigFile                         1 calls
1>        0 ms  Build                                      1 calls
1>        0 ms  DeleteBuildInfoFile                        1 calls
1>        0 ms  CleanXsdCodeGen                            1 calls
1>        0 ms  _SetupInstantRun                           1 calls
1>        0 ms  GetFrameworkPaths                          1 calls
1>        0 ms  DeleteBuildInfoResource                    1 calls
1>        0 ms  _AddAndroidDefines                         1 calls
1>        0 ms  BuildOnlySettings                          1 calls
1>        0 ms  ComputeIntermediateSatelliteAssemblies     1 calls
1>        0 ms  ValidationExtension                        1 calls
1>        0 ms  AfterCompile                               1 calls
1>        0 ms  _CheckInstantRunCondition                  1 calls
1>        0 ms  _GenerateSatelliteAssemblyInputs           1 calls
1>        0 ms  _SetupApplicationJavaClass                 1 calls
1>        0 ms  _SetupDesignTimeBuildForIntellisense       1 calls
1>        0 ms  SetWin32ManifestProperties                 1 calls
1>        0 ms  CreateSatelliteAssemblies                  1 calls
1>        0 ms  _CopySourceItemsToOutputDirectory          1 calls
1>        0 ms  GetInstalledSDKLocations                   1 calls
1>        0 ms  _AddAndroidEnvironmentToCompile            1 calls
1>        0 ms  _CheckForContent                           1 calls
1>        0 ms  _SeparateAppExtensionReferences            1 calls
1>        0 ms  AfterResolveReferences                     1 calls
1>        0 ms  BeforeResolveReferences                    1 calls
1>        0 ms  PrepareResources                           1 calls
1>        0 ms  ResolveSDKReferences                       1 calls
1>        0 ms  _CheckForDeletedResourceFile               1 calls
1>        0 ms  BeforeCompile                              1 calls
1>        0 ms  UpdateAndroidAssets                        1 calls
1>        0 ms  DesignTimeXamlMarkupCompilation            1 calls
1>        0 ms  _AddMultiDexDependencyJars                 1 calls
1>        0 ms  PrepareForRun                              1 calls
1>        0 ms  ResGen                                     1 calls
1>        0 ms  _GenerateAndroidAssetsDir                  1 calls
1>        0 ms  AfterBuild                                 1 calls
1>        0 ms  BclBuildSetRunningFullBuild                1 calls
1>        0 ms  GetNativeManifest                          2 calls
1>        0 ms  ExpandSDKReferences                        1 calls
1>        0 ms  GenerateTargetFrameworkMonikerAttribute    1 calls
1>        0 ms  _GenerateAndroidResourceDir                1 calls
1>        0 ms  CreateManifestResourceNames                1 calls
1>        0 ms  BeforeBuild                                1 calls
1>        0 ms  _GenerateCompileInputs                     1 calls
1>        0 ms  _SetupDesignTimeBuildForBuild              1 calls
1>        0 ms  PrepareResourceNames                       1 calls
1>        0 ms  _AddNativeLibraryArchiveToCompile          1 calls
1>        1 ms  GetCopyToOutputDirectoryXamlAppDefs        3 calls
1>        1 ms  _GenerateJavaDesignerForComponent          1 calls
1>        1 ms  _CollectMonoAndroidOutputs                 1 calls
1>        1 ms  _SetEmbeddedWin32ManifestProperties        1 calls
1>        1 ms  CoreResGen                                 1 calls
1>        1 ms  _ValidateLinkMode                          1 calls
1>        1 ms  _GetLibraryImports                         1 calls
1>        1 ms  _CheckForCompileOutputs                    1 calls
1>        1 ms  _ReadPropertiesCache                       1 calls
1>        1 ms  GetTargetPath                              2 calls
1>        1 ms  _ComputeAndroidResourcePaths               1 calls
1>        1 ms  SetBuildInfoDefaults                       1 calls
1>        1 ms  SplitResourcesByCulture                    1 calls
1>        1 ms  _SplitProjectReferencesByFileExistence     3 calls
1>        1 ms  GenerateCompiledExpressionsTempFile        1 calls
1>        1 ms  BclBuildDetermineReferencesToRedirect      1 calls
1>        1 ms  _GetReferenceAssemblyPaths                 1 calls
1>        1 ms  PreXsdCodeGen                              1 calls
1>        2 ms  _RegisterMdbFilesWithFileWrites            1 calls
1>        2 ms  PrepareForBuild                            1 calls
1>        2 ms  _BuildSdkCache                             1 calls
1>        2 ms  _CalculateAdditionalResourceCacheDirectories   1 calls
1>        2 ms  AssignProjectConfiguration                 1 calls
1>        2 ms  _CreateAdditionalResourceCache             1 calls
1>        2 ms  GetReferenceAssemblyPaths                  1 calls
1>        3 ms  _GetAdditionalResourcesFromAssemblies      1 calls
1>        3 ms  _CheckDuplicateJavaLibraries               1 calls
1>        3 ms  _CollectAdditionalResourceFiles            1 calls
1>        3 ms  _ExtractLibraryProjectImports              1 calls
1>        3 ms  _ComputeAndroidAssetsPaths                 1 calls
1>        3 ms  AssignTargetPaths                          3 calls
1>        3 ms  CopyFilesToOutputDirectory                 1 calls
1>        4 ms  _ValidateResourceCache                     1 calls
1>        4 ms  _ValidateAndroidPackageProperties          1 calls
1>        5 ms  IncrementalClean                           1 calls
1>        7 ms  _ResolveMonoAndroidSdks                    1 calls
1>        9 ms  _CheckForInvalidConfigurationAndPlatform   3 calls
1>       10 ms  GetCopyToOutputDirectoryItems              3 calls
1>       11 ms  _CopyFilesMarkedCopyLocal                  1 calls
1>       11 ms  _CleanGetCurrentAndPriorFileWrites         1 calls
1>       12 ms  _AddLibraryProjectsEmbeddedResourceToProject   1 calls
1>       18 ms  ImplicitlyExpandDesignTimeFacades          1 calls
1>       29 ms  _BuildLibraryImportsCache                  1 calls
1>       41 ms  ResolveProjectReferences                   1 calls
1>       70 ms  _SetLatestTargetFrameworkVersion           1 calls
1>      114 ms  _ResolveLibraryProjectImports              1 calls
1>      138 ms  ResolveAssemblyReferences                  1 calls
1>      207 ms  _UpdateAndroidResgen                       1 calls
1>      356 ms  _GetPrimaryCpuAbi                          1 calls
1>      803 ms  CoreCompile                                1 calls
1>    38202 ms  _BuildAdditionalResourcesCache             1 calls
1>
1>Task Performance Summary:
1>        0 ms  CreateCSharpManifestResourceName           1 calls
1>        0 ms  Delete                                     2 calls
1>        0 ms  FindAppConfigFile                          1 calls
1>        0 ms  ResolveCodeAnalysisRuleSet                 1 calls
1>        0 ms  CallTarget                                 1 calls
1>        0 ms  ResolveNonMSBuildProjectOutput             1 calls
1>        0 ms  AssignCulture                              1 calls
1>        1 ms  GetFrameworkPath                           1 calls
1>        1 ms  GetAndroidPackageName                      1 calls
1>        1 ms  AssignProjectConfiguration                 1 calls
1>        1 ms  ReadImportedLibrariesCache                 1 calls
1>        1 ms  ReadLinesFromFile                          2 calls
1>        1 ms  GetAppSettingsDirectory                    1 calls
1>        1 ms  AssignTargetPath                          18 calls
1>        1 ms  CreateTemporaryDirectory                   1 calls
1>        1 ms  GetReferenceAssemblyPaths                  2 calls
1>        2 ms  Message                                   20 calls
1>        2 ms  CalculateAdditionalResourceCacheDirectories   1 calls
1>        2 ms  GetJavaPlatformJar                         1 calls
1>        2 ms  MakeDir                                    2 calls
1>        2 ms  WriteLinesToFile                           1 calls
1>        2 ms  ConvertToAbsolutePath                      1 calls
1>        3 ms  RemoveDuplicates                           2 calls
1>        3 ms  CopyIfChanged                              1 calls
1>        3 ms  CheckDuplicateJavaLibraries                1 calls
1>        3 ms  AndroidComputeResPaths                     2 calls
1>        3 ms  ReadLibraryProjectImportsCache             1 calls
1>        3 ms  CreateProperty                            41 calls
1>        4 ms  CopyGeneratedJavaResourceClasses           1 calls
1>        4 ms  GetExtraPackages                           1 calls
1>        4 ms  GetAndroidDefineConstants                  1 calls
1>        4 ms  CreateAndroidResourceStamp                 1 calls
1>        5 ms  FindUnderPath                              5 calls
1>        5 ms  ReadAdditionalResourcesFromAssemblyCache   2 calls
1>        5 ms  CreateResgenManifest                       1 calls
1>        6 ms  CreateItem                                23 calls
1>        6 ms  RemoveDirFixed                             1 calls
1>       12 ms  CreateManagedLibraryResourceArchive        1 calls
1>       14 ms  Copy                                       3 calls
1>       16 ms  ConvertResourcesCases                      1 calls
1>       21 ms  GenerateResourceDesigner                   1 calls
1>       28 ms  GetImportedLibraries                       1 calls
1>       49 ms  MSBuild                                    3 calls
1>       49 ms  ReadResolvedSdksCache                      1 calls
1>      114 ms  ResolveLibraryProjectImports               1 calls
1>      137 ms  ResolveAssemblyReference                   1 calls
1>      142 ms  Aapt                                       1 calls
1>      347 ms  GetPrimaryCpuAbi                           1 calls
1>      792 ms  Csc                                        1 calls
1>    38201 ms  GetAdditionalResourcesFromAssemblies       1 calls
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:40.09

There is a second summary (the log has 2 of these summaries somehow), but I can't include it in the question, because it would exceed the body character limit. Smaller version of the second summary:

2>Project Performance Summary:
2>        6 ms  C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAll.App.Shared\OverAll.App.Shared.csproj   5 calls
2>                  0 ms  GetTargetPath                              1 calls
2>                  0 ms  GetNativeManifest                          1 calls
2>                  1 ms  GetCopyToOutputDirectoryItems              1 calls
2>                  5 ms  GetBuiltProjectOutputRecursive             2 calls
2>        9 ms  C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAllField.XamarinAndroid.BarcodeScanner\OverAllField.XamarinAndroid.BarcodeScanner.csproj   4 calls
2>                  0 ms  GetTargetPath                              1 calls
2>                  2 ms  GetNativeManifest                          1 calls
2>                  3 ms  GetCopyToOutputDirectoryItems              1 calls
2>                  4 ms  GetBuiltProjectOutputRecursive             1 calls
2>       17 ms  C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAllField.XamarinAndroid.DataLayer\OverAllField.XamarinAndroid.DataLayer.csproj   5 calls
2>                  9 ms  GetTargetPath                              1 calls
2>                  1 ms  GetNativeManifest                          1 calls
2>                  2 ms  GetCopyToOutputDirectoryItems              1 calls
2>                  5 ms  GetBuiltProjectOutputRecursive             2 calls
2>       46 ms  C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAllField.XamarinAndroid.ServiceClient\OverAllField.XamarinAndroid.ServiceClient.csproj   4 calls
2>                 21 ms  GetTargetPath                              1 calls
2>                  0 ms  GetNativeManifest                          1 calls
2>                  2 ms  GetCopyToOutputDirectoryItems              1 calls
2>                 23 ms  GetBuiltProjectOutputRecursive             1 calls
2>    87736 ms  C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAllField.Android\OverAllField.XamarinAndroid.csproj   1 calls

Second Target Performance Summary: (removed anything <1000 ms to reduce chars)

2>     1955 ms  _GenerateJavaStubs                         1 calls
2>     3083 ms  _CreateBaseApk                             1 calls
2>     3467 ms  _UpdateAndroidResgen                       1 calls
2>     8944 ms  _CompileToDalvikWithDx                     1 calls
2>    66321 ms  _BuildAdditionalResourcesCache             1 calls

Second Task Performance Summary: (again, removed anything <1000 ms to reduce chars)

2>     1245 ms  GenerateJavaStubs                          1 calls
2>     2334 ms  ConvertResourcesCases                      3 calls
2>     4637 ms  Aapt                                       2 calls
2>     8941 ms  CompileToDalvik                            1 calls
2>    66320 ms  GetAdditionalResourcesFromAssemblies       1 calls
2>
2>Build succeeded.
2>
2>Time Elapsed 00:01:27.73

Full diagnostic build log here

UPDATE 4

Full diagnostic build log with Android support version 23 here

There is a significant difference between the build times. Support version 24:

1>Project Performance Summary:
1>    40103 ms  C:\Development\Apps\trunk\App.Droid\App.Droid.ServiceClient\App.Droid.ServiceClient.csproj   1 calls
...
2>Project Performance Summary:
2>    87736 ms  C:\Development\Apps\trunk\App.Droid\App.Droid\App.Droid.csproj   1 calls

Support version 23:

1>Project Performance Summary:
1>      962 ms  C:\Development\Apps\trunk-r1029\App.Droid\App.Droid.ServiceClient\App.Droid.ServiceClient.csproj   1 calls
2>Project Performance Summary:
2>    18214 ms  C:\Development\Apps\trunk-r1029\App.Droid\App.Droid\App.Droid.csproj   1 calls

Both are built with target Android 7.0 and the same Xamarin version, the only difference is the Android Support library version. Isn't that a huge increase?

Thanks in advance!

like image 687
avb Avatar asked Nov 10 '16 08:11

avb


People also ask

Is Xamarin slow?

The build is extremely slow compared to Visual Studio. With the ReSharper build in Rider it takes ~10 minutes. Without it takes ~8 minutes in Rider.

Is Xamarin faster than flutter?

The speed of development required: Xamarin provides better development tools than Flutter, and it's easier to use. If you need fast development, use Xamarin. Availability of developers: You will find Flutter developers easier than Xamarin since it's more popular. Flutter is also more loved than Xamarin.

Is Xamarin faster than react native?

Though both Xamarin and React Native offer near-native performance, Xamarin runs the fastest code on Android and iOS and has a user interface (UI) for using native tools. TLDR: In Xamarin vs. React Native, Xamarin has more brownie points for native-like performance. Xamarin wins.


1 Answers

Although this is a very "tough" question to answer as build times can be dependent on many different factors, I can walk you through ways to determine what in your build is causing the delay. In most cases it's typically because of non-optimized Resources. This can be resources like raw images/audio/video that really should be optimized for mobile.

As for the experimental functionality you mentioned, you can view the release notes here:

https://developer.xamarin.com/releases/android/xamarin.android_7/xamarin.android_7.0/#Improved_Fast_Deployment

Note: This is experimental, thus it does not guarantee it will be stable enough to use in production.

As for Build Times, we need to know where the bottleneck is within your project. To do this, you need to enable Diagnostic Build Output in your build-agent's command. This is pretty simple with MSBuild via:

/v:diag or /verbosity:diagnostic (Or whatever combination you wanted)

and

/clp:PerformanceSummary - Which will tell use the performance timings of each task

https://msdn.microsoft.com/en-us/library/ms164311.aspx

EX: Building a File->New Android Project:

1>Project Performance Summary:
1>     4087 ms  c:\users\dougl\documents\visual studio 2015\Projects\App26\App26\App26.csproj   1 calls
1>               4087 ms  Rebuild                                    1 calls
1>
1>Target Performance Summary:
1>        0 ms  GetCopyToOutputDirectoryXamlAppDefs        1 calls
1>        0 ms  BeforeRebuild                              1 calls
1>        0 ms  PrepareResources                           1 calls
1>        0 ms  _DefineBuildTargetAbis                     1 calls
1>        0 ms  UpdateAndroidAssets                        1 calls
1>        0 ms  AfterBuild                                 1 calls
1>        0 ms  AfterCompile                               1 calls
1>        0 ms  BeforeCompile                              1 calls
1>        0 ms  ExpressionBuildExtension                   1 calls
1>        0 ms  _GenerateCompileInputs                     1 calls
1>        0 ms  ResolveCodeAnalysisRuleSet                 1 calls
1>        0 ms  _LinkAssemblies                            1 calls
1>        0 ms  GetTargetPath                              1 calls
1>        0 ms  Build                                      1 calls
1>        0 ms  GenerateCompiledExpressionsTempFile        1 calls
1>        0 ms  _CopyConfigFiles                           1 calls
1>        0 ms  Compile                                    1 calls
1>        0 ms  Rebuild                                    1 calls
1>        0 ms  ModifyUnitTestPlatformVersion              1 calls
1>        0 ms  _RegisterMdbFilesWithFileWrites            1 calls
1>        0 ms  _CheckForCompileOutputs                    1 calls
1>        0 ms  _SetupDesignTimeBuildForIntellisense       1 calls
1>        0 ms  _SetTargetFrameworkMonikerAttribute        1 calls
1>        0 ms  _GenerateAndroidAssetsDir                  1 calls
1>        0 ms  _AddMultiDexDependencyJars                 1 calls
1>        0 ms  AfterResolveReferences                     1 calls
1>        0 ms  UpdateAndroidResources                     1 calls
1>        0 ms  _CheckInstantRunCondition                  1 calls
1>        0 ms  CleanPublishFolder                         1 calls
1>        0 ms  _CheckTargetFramework                      1 calls
1>        0 ms  _CollectMonoAndroidOutputs                 1 calls
1>        0 ms  _CopySourceItemsToOutputDirectory          1 calls
1>        0 ms  CompileRdlFiles                            1 calls
1>        0 ms  _CreateAdditionalResourceCache             4 calls
1>        0 ms  DesignTimeXamlMarkupCompilation            1 calls
1>        0 ms  AfterRebuild                               1 calls
1>        0 ms  _SeparateAppExtensionReferences            1 calls
1>        0 ms  ExpandSDKReferences                        1 calls
1>        0 ms  _ReadPropertiesCache                       1 calls
1>        0 ms  AfterResGen                                1 calls
1>        0 ms  CleanReferencedProjects                    1 calls
1>        0 ms  _CollectPCLPdbFiles                        1 calls
1>        0 ms  Clean                                      1 calls
1>        0 ms  SetWin32ManifestProperties                 1 calls
1>        0 ms  ResolveSDKReferences                       1 calls
1>        0 ms  CreateSatelliteAssemblies                  1 calls
1>        0 ms  DeleteBuildInfoResource                    1 calls
1>        0 ms  _ResolveMonoAndroidFramework               1 calls
1>        0 ms  PrepareResourceNames                       1 calls
1>        0 ms  _SetupInstantRun                           1 calls
1>        0 ms  _SetupDesignTimeBuildForBuild              1 calls
1>        0 ms  CoreBuild                                  1 calls
1>        0 ms  _CheckForDeletedResourceFile               1 calls
1>        0 ms  GetFrameworkPaths                          1 calls
1>        0 ms  _ValidateLinkMode                          1 calls
1>        0 ms  DeleteBuildInfoFile                        1 calls
1>        0 ms  _CollectPCLMdbFiles                        1 calls
1>        0 ms  _CompileDex                                1 calls
1>        0 ms  GetInstalledSDKLocations                   1 calls
1>        0 ms  BeforeClean                                1 calls
1>        0 ms  BuildOnlySettings                          1 calls
1>        0 ms  _ValidateResourceCache                     1 calls
1>        0 ms  BeforeResolveReferences                    1 calls
1>        0 ms  _CheckForContent                           1 calls
1>        0 ms  BeforeResGen                               1 calls
1>        0 ms  PrepareRdlFiles                            1 calls
1>        0 ms  AfterClean                                 1 calls
1>        0 ms  _SetupApplicationJavaClass                 1 calls
1>        0 ms  ValidationExtension                        1 calls
1>        0 ms  _IncludeInstanceRunReference               1 calls
1>        0 ms  ResolveReferences                          1 calls
1>        0 ms  CreateCustomManifestResourceNames          1 calls
1>        0 ms  ResGen                                     1 calls
1>        0 ms  BeforeBuild                                1 calls
1>        1 ms  _SplitProjectReferencesByFileExistence     1 calls
1>        1 ms  _GenerateSatelliteAssemblyInputs           1 calls
1>        1 ms  PrepareForRun                              1 calls
1>        1 ms  CleanXsdCodeGen                            1 calls
1>        1 ms  GenerateTargetFrameworkMonikerAttribute    1 calls
1>        1 ms  ResolveProjectReferences                   1 calls
1>        1 ms  AssignTargetPaths                          1 calls
1>        1 ms  _CreateIntermediateAssembliesDir           1 calls
1>        1 ms  GetCopyToOutputDirectoryItems              1 calls
1>        1 ms  PreXsdCodeGen                              1 calls
1>        1 ms  _GetReferenceAssemblyPaths                 1 calls
1>        1 ms  CoreResGen                                 1 calls
1>        1 ms  _CleanGeneratedDeploymentFiles             1 calls
1>        1 ms  SetBuildInfoDefaults                       1 calls
1>        1 ms  AssignProjectConfiguration                 1 calls
1>        1 ms  _CreatePackageWorkspace                    1 calls
1>        1 ms  _GetMonoPlatformJarPath                    1 calls
1>        1 ms  PrepareForBuild                            1 calls
1>        1 ms  _CalculateAdditionalResourceCacheDirectories   1 calls
1>        1 ms  _ComputeAndroidResourcePaths               1 calls
1>        1 ms  _SetEmbeddedWin32ManifestProperties        1 calls
1>        1 ms  _GetAddOnPlatformLibraries                 1 calls
1>        1 ms  _GetLibraryImports                         1 calls
1>        1 ms  SplitResourcesByCulture                    1 calls
1>        1 ms  GetReferenceAssemblyPaths                  1 calls
1>        1 ms  _CheckProjectItems                         1 calls
1>        1 ms  _AdjustJavacVersionArguments               1 calls
1>        1 ms  _CleanGeneratedDebuggingFiles              1 calls
1>        2 ms  _PrepareAssemblies                         1 calls
1>        2 ms  _FindJavaStubFiles                         1 calls
1>        2 ms  _ExtractLibraryProjectImports              1 calls
1>        2 ms  _StripEmbeddedLibraries                    1 calls
1>        2 ms  _CleanGetCurrentAndPriorFileWrites         1 calls
1>        2 ms  _GetAdditionalResourcesFromAssemblies      1 calls
1>        2 ms  _FindCompiledJavaFiles                     1 calls
1>        2 ms  _CheckDuplicateJavaLibraries               1 calls
1>        2 ms  _AddLibraryProjectsEmbeddedResourceToProject   1 calls
1>        3 ms  _ComputeAndroidAssetsPaths                 1 calls
1>        3 ms  CopyFilesToOutputDirectory                 1 calls
1>        3 ms  CoreClean                                  1 calls
1>        3 ms  _CollectPdbFiles                           1 calls
1>        3 ms  GetBuiltProjectOutputRecursive             1 calls
1>        3 ms  _CollectConfigFiles                        1 calls
1>        3 ms  _ValidateAndroidPackageProperties          1 calls
1>        3 ms  _WriteResolvedAssemblies                   1 calls
1>        4 ms  _CreatePropertiesCache                     1 calls
1>        4 ms  _ResolveMonoAndroidSdks                    1 calls
1>        4 ms  _AddDebugStaticResources                   1 calls
1>        4 ms  _BuildLibraryImportsCache                  1 calls
1>        4 ms  _CollectMdbFiles                           1 calls
1>        5 ms  _CheckForInvalidConfigurationAndPlatform   1 calls
1>        7 ms  _ResolveSatellitePaths                     1 calls
1>        7 ms  _GeneratePackageManagerJava                1 calls
1>        8 ms  _DetermineJavaLibrariesToCompile           1 calls
1>        9 ms  IncrementalClean                           1 calls
1>       10 ms  _AddStaticResources                        1 calls
1>       11 ms  _CleanMonoAndroidIntermediateDir           1 calls
1>       11 ms  _GenerateAndroidResourceDir                1 calls
1>       12 ms  _CleanMsymArchive                          1 calls
1>       18 ms  _SetLatestTargetFrameworkVersion           1 calls
1>       20 ms  ResolveAssemblyReferences                  1 calls
1>       27 ms  ImplicitlyExpandDesignTimeFacades          1 calls
1>       30 ms  _BuildSdkCache                             1 calls
1>       35 ms  _ConvertPdbFiles                           1 calls
1>       45 ms  _CheckTargetFrameworks                     1 calls
1>       46 ms  _ResolveLibraryProjectImports              1 calls
1>       52 ms  _CreateBaseApk                             1 calls
1>       66 ms  _BuildAdditionalResourcesCache             1 calls
1>       72 ms  _CopyMdbFiles                              1 calls
1>       78 ms  _ResolveAssemblies                         1 calls
1>      115 ms  _UpdateAndroidResgen                       1 calls
1>      167 ms  _GenerateJavaStubs                         1 calls
1>      189 ms  _GetPrimaryCpuAbi                          1 calls
1>      453 ms  _CopyIntermediateAssemblies                1 calls
1>      515 ms  _LinkAssembliesNoShrink                    1 calls
1>      657 ms  _CompileToDalvikWithDx                     1 calls
1>      664 ms  _CompileJava                               1 calls
1>      677 ms  CoreCompile                                1 calls
1>
1>Task Performance Summary:
1>        0 ms  CallTarget                                 1 calls
1>        0 ms  MSBuild                                    1 calls
1>        0 ms  ResolveCodeAnalysisRuleSet                 1 calls
1>        0 ms  ReadLinesFromFile                          2 calls
1>        0 ms  GetFrameworkPath                           1 calls
1>        0 ms  FindAppConfigFile                          1 calls
1>        0 ms  AssignCulture                              1 calls
1>        1 ms  GetAppSettingsDirectory                    1 calls
1>        1 ms  ConvertToAbsolutePath                      1 calls
1>        1 ms  RemoveDuplicates                           3 calls
1>        1 ms  AssignTargetPath                           6 calls
1>        1 ms  CollectLibraryAssets                       1 calls
1>        1 ms  AssignProjectConfiguration                 1 calls
1>        1 ms  GetMonoPlatformJar                         1 calls
1>        1 ms  CalculateAdditionalResourceCacheDirectories   1 calls
1>        1 ms  CreateTemporaryDirectory                   2 calls
1>        1 ms  GetAndroidDefineConstants                  1 calls
1>        1 ms  GetAddOnPlatformLibraries                  1 calls
1>        1 ms  ReadImportedLibrariesCache                 1 calls
1>        1 ms  ReadAdditionalResourcesFromAssemblyCache   1 calls
1>        1 ms  CheckProjectItems                          1 calls
1>        1 ms  GetReferenceAssemblyPaths                  2 calls
1>        1 ms  AdjustJavacVersionArguments                1 calls
1>        2 ms  FindUnderPath                              7 calls
1>        2 ms  Message                                   17 calls
1>        2 ms  ReadLibraryProjectImportsCache             1 calls
1>        2 ms  MakeDir                                    6 calls
1>        2 ms  CreateAndroidResourceStamp                 1 calls
1>        2 ms  CreateProperty                            42 calls
1>        2 ms  CopyIfChanged                              1 calls
1>        2 ms  GetAndroidPackageName                      2 calls
1>        2 ms  GetJavaPlatformJar                         1 calls
1>        2 ms  GetExtraPackages                           2 calls
1>        2 ms  CheckDuplicateJavaLibraries                1 calls
1>        2 ms  CreateManagedLibraryResourceArchive        1 calls
1>        3 ms  RemoveUnknownFiles                         1 calls
1>        3 ms  AndroidComputeResPaths                     2 calls
1>        3 ms  CreateResgenManifest                       1 calls
1>        4 ms  GetImportedLibraries                       1 calls
1>        4 ms  GetFilesThatExist                          3 calls
1>        6 ms  Touch                                      7 calls
1>        6 ms  CopyGeneratedJavaResourceClasses           2 calls
1>        7 ms  CreateItem                                20 calls
1>        7 ms  GeneratePackageManagerJava                 1 calls
1>        7 ms  DetermineJavaLibrariesToCompile            1 calls
1>        8 ms  Delete                                    28 calls
1>       10 ms  CopyResource                               4 calls
1>       11 ms  RemoveDirFixed                             5 calls
1>       12 ms  WriteLinesToFile                           5 calls
1>       17 ms  ReadResolvedSdksCache                      1 calls
1>       27 ms  ResolveAssemblyReference                   2 calls
1>       29 ms  GenerateResourceDesigner                   1 calls
1>       29 ms  ResolveSdks                                1 calls
1>       29 ms  ConvertResourcesCases                      3 calls
1>       35 ms  ConvertDebuggingFiles                      1 calls
1>       45 ms  CheckTargetFrameworks                      1 calls
1>       45 ms  ResolveLibraryProjectImports               1 calls
1>       52 ms  CopyMdbFiles                               1 calls
1>       65 ms  GetAdditionalResourcesFromAssemblies       1 calls
1>       77 ms  ResolveAssemblies                          1 calls
1>       92 ms  Aapt                                       2 calls
1>      161 ms  GenerateJavaStubs                          1 calls
1>      186 ms  GetPrimaryCpuAbi                           1 calls
1>      479 ms  Copy                                       7 calls
1>      513 ms  LinkAssemblies                             1 calls
1>      655 ms  CompileToDalvik                            1 calls
1>      660 ms  Csc                                        1 calls
1>      664 ms  Javac                                      1 calls
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:04.08

Notice that we can tell how long this build took: 4 seconds. However that doesn't answer your case, but with a proper log like this, we can then investigate that Target or Task and figure out what your project is bottlenecking on. My guess would be aapt, but that's just because even Android Studio would hang here as this tooling is inside the Android SDK and it responsible for packaging android assets.

EDIT:

It looks like this build took ~2 minutes to build the 2 projects. One being in C:\Development\Apps\trunk\App.Droid\App.Droid.ServiceClient\App.Droid.ServiceClient.csproj and the other in C:\Development\Apps\trunk\App.Droid\App.Droid\App.Droid.csproj (40 / 87 seconds respectively). This seems quite normal for a project with this many third party dependencies to Android Support / Google Play. You can search the string Task "GetAdditionalResourcesFromAssemblies to show 6 places where this is defined. There are 2 Tasks being invoked here due to the 2 Android projects.

It might be worth a comparison of an Android Studio project with that many external dependencies and compare the time. I do know that we currently have quite a bit of on-going work with regards to the GetAdditionalResourcesFromAssemblies Task. However this work won't be available until Cycle 9-10. This work is currently apart of a pull request:

https://github.com/xamarin/xamarin-android/pull/296

(You can tell it's almost brand new due to the commit time).

As you can tell from this Task, there will be the following improvements:

The current Task always downloads data from google. This is regardless of whether the files exist in the Android sdk directory already. This commit changes the GetAdditionalResourcesFromAssemblies task to look in the "extras" folder in the android sdk for the required .aar file. This will mean if a user has an up to date sdk, there will be almost no need to download the files from the internet.

There's also a PR - https://github.com/xamarin/xamarin-android/pull/292 (Thanks @Mikhail)

Which addresses reusing the computed hash which can also lower build times.

TLDR; GetAdditionalResourcesFromAssemblies needs a bit more work for build times to be shorter. This is currently in the works.

EDIT 2:

This is currently resolved in support libraries that include a dependency to https://www.nuget.org/packages/Xamarin.Build.Download/

like image 160
Jon Douglas Avatar answered Sep 19 '22 22:09

Jon Douglas