Bug 34562

Summary: Xamarin.Android hangs VS for long periods when installing NuGet packages
Product: Android Reporter: Matt Ward <matt.ward>
Component: MSBuildAssignee: dean.ellis
Status: VERIFIED FIXED    
Severity: critical CC: joe, jonp, kzu, mono-bugs+bugzilla, mono-bugs+monodroid, peter.collins
Priority: High    
Version: 5.1   
Target Milestone: 6.0 (C6)   
Hardware: PC   
OS: Windows   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: hangcallstack

Description Matt Ward 2015-10-05 11:59:23 UTC
Created attachment 13193 [details]
hangcallstack

Originally raised on the forum by Andrew Arnott:

http://forums.xamarin.com/discussion/52746/xamarin-android-hangs-vs-for-long-periods

When installing a NuGet package to a new Xamarin.Android project, VS hung for several minutes. I broke into VS with the debugger and found via the callstack (attached) that the hang is caused by the NuGet package manager enumerating references, causing the C# project system to request a synchronous design-time build on the UI thread, leading to MSBuild running a Xamarin.Android task. The Xamarin.Android task downloads many megabytes of data from the Internet. This seems very inappropriate for a design-time build, which is supposed to run in under 200ms. Please adjust your Xamarin.Android MSBuild targets to skip expensive tasks like this during design-time builds!
Comment 1 Peter Collins 2015-10-06 14:28:46 UTC
I'm able to reproduce this on the current stable as well as active Cycle 6 builds. I'm not entirely sure how much of an impact clearing the NuGet/Xamarin package caches has on this, however attempting to add GooglePlayServices - All from a clean state is certainly quite painful.

Steps to reproduce:
1. Delete the following cache locations if they exist:
> %LOCALAPPDATA%\NuGet\Cache
> %LOCALAPPDATA%\Xamarin\Android.Support.*
> %LOCALAPPDATA%\Xamarin\GooglePlayServices.*
2. Create a new hello world android template
3. Right click on the project/solution -> Manage NuGet Packages...
4. Search for "Google Play Services All", select and install that option once it appears.

With this workflow, you can see VS free up _briefly_ in between package additions. However if you're attempting to add 5+ packages or so (quite noticeable when adding all of the google play services packages), this results in a few minutes of unresponsiveness.
Comment 2 dean.ellis 2015-10-23 15:41:20 UTC
Fixed in monodroid/master/39ee3143

We added support for DesignTimeBuild property. The VS team also needed to add support for passing that property as part of the UpdateAndroidResources call.
Comment 3 Jose Gallardo 2015-11-12 07:11:43 UTC
*** Bug 35797 has been marked as a duplicate of this bug. ***
Comment 4 Peter Collins 2015-11-13 12:34:50 UTC
This is verified fixed against xamarinvs/cycle6/860fe435 (monodroid/cycle6/3efa14c)