Created attachment 25236 [details]
MoreData for issue like version+XamarinLog+VS screenshot
After upgrading to latest Xamarin with the latest stable version which is release on 09-Oct-2017 my Visual studio 2015 getting hang when I am trying to open/load my project solution, It loads all the projects but stuck while initializing the Android project. After that only option remains to kill the Visual studio. Problem starts after taking Xamarin update. If I remove Android projects from solution then it loads properly.
Attaching screen shot for more details-
Version info - version.jpg
Xamarin Log for ide- 2017-10-10_13-35-10.15492.Ide.log
Visual studio screenshot where it stuck -
Just to add on - When i downgrade my Xamarin.Android to 220.127.116.11 from 18.104.22.168, it start working as previously.
I'm running into the same issue, but it isn't reproducible quite 100% of the time. I did get lucky yesterday and got the solution to load once or twice. I'm attaching two log files, one from when it successfully loads the solution/project, and one when it doesn't.
Created attachment 25286 [details]
Successful project load
This is a log file from a successful attempt at loading a Xamarin.Android project with v4.7 of the VS extension
Created attachment 25287 [details]
Failed project load
This is a log file from a failed attempt at loading a Xamarin.Android project with v4.7 of the VS extension
Created attachment 25292 [details]
Failed to load project
Project was loading correctly until i started working on iOS project. It is hanging every time i open the Solution.
I figured a work around - remove the android projects from solution and add it after solution is loaded.
Victor you might also want to try deleting the .vs folder as a work around too. In the mean time we are investigating this issue.
Thanks Dean! Deleting .vs folder also worked.
Created attachment 25327 [details]
mini dump file
I am including some additional information that may help the investigation. I am attaching the mini dump gathered from a hanging VS instance (the full dump is also available if necessary) as well as the design time logs gathered both from when VS successfully loads the solution and when it hangs.
The dump file shows this call stack from the main thread which seems to indicate the hang is a result of the GetAdditionalResourcesFromAssemblies task:
> [Managed to Native Transition]
> WindowsBase.dll!System.Windows.Threading.DispatcherSynchronizationContext.Wait(System.IntPtr waitHandles, bool waitAll, int millisecondsTimeout) Unknown
> mscorlib.dll!System.Threading.SynchronizationContext.InvokeWaitMethodHelper(System.Threading.SynchronizationContext syncContext, System.IntPtr waitHandles, bool waitAll, int millisecondsTimeout) Unknown
> [Native to Managed Transition]
> [Managed to Native Transition]
> mscorlib.dll!System.Threading.WaitHandle.WaitAny(System.Threading.WaitHandle waitHandles, int millisecondsTimeout, bool exitContext) Unknown
> mscorlib.dll!System.Threading.WaitHandle.WaitAny(System.Threading.WaitHandle waitHandles, System.TimeSpan timeout, bool exitContext) Unknown
> Xamarin.Android.Build.Tasks.dll!Xamarin.Android.Tasks.AsyncTask.WaitForCompletion() Unknown
> Xamarin.Android.Build.Tasks.dll!Xamarin.Android.Tasks.AsyncTask.Execute() Unknown
> Xamarin.Android.Build.Tasks.dll!Xamarin.Android.Tasks.GetAdditionalResourcesFromAssemblies.Execute() Unknown
> Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() Unknown
> Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) Unknown
> mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26>(ref Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26 stateMachine) Unknown
Full stack trace: https://gist.github.com/jimmgarrido/b947d9744dfc06290b3a19720e774b51
I have not been able to find definite steps to reproduce the issue with a new project, but I got the above information from an existing project on my machine that began exhibiting the issue. However I zipped up the entire project, including the .vs directory, but after it was unzipped it did not reproduce the issue so sharing the solution does not seem helpful in this case unfortunately.
Created attachment 25328 [details]
design time build logs
*** Bug 60158 has been marked as a duplicate of this bug. ***
Based off logs in MyTestingApp_Compile_f91ef4fd.designtime.log:
We can see that the Task "GetAdditionalResourcesFromAssemblies" is hanging indefinitely and most likely causing the Visual Studio hangs.
From the minidump, it seemms that the "AsyncTask" inherited by "GetAdditionalResourcesFromAssemblies" Task is hanging on a WaitHandle. More specifically it seems to be the following line of code: https://github.com/xamarin/xamarin-android/blob/d15-4/src/Xamarin.Android.Build.Tasks/Tasks/AsyncTask.cs#L277
Thus I would like to invite anyone reading this message to provide a dump file(https://developer.xamarin.com/guides/cross-platform/windows/visual-studio/troubleshooting/vs-callstack/) and/or design time build logs(https://github.com/dotnet/project-system/blob/master/docs/design-time-builds.md#getting-visual-studio-to-output-the-results-of-a-design-time-build) when they encounter this issue so we can ensure that this is the same case across the board.
In the meantime, we will be further investigating this issue and trying to come up with a more reliable reproduction.
## Bookkeeping note
I am marking the issue as confirmed based on Comment 9, and I am setting the target milestone to 15.4 SR2 for initial investigation based on the number of user reports that indicate a regression in behavior compared to the Xamarin 15.3 Release.
Created attachment 25368 [details]
Modified .targets files for workaround
## Workaround (that might re-break Bug 57281)
Add back the following attribute on the `GetAdditionalResourcesFromAssemblies` Task element in Xamarin.Android.Common.targets and Xamarin.Android.Bindings.targets:
Condition=" '$(DesignTimeBuild)' == 'false' Or '$(DesignTimeBuild)' == '' "
In case it might be helpful, I have attached modified files with this 1-line change onto this comment. (You can use `fc` (https://technet.microsoft.com/library/bb490904.aspx) in a cmd.exe command prompt to compare these files to the original versions for verification before overwriting the originals.)
1. Download the attached .zip file.
2. Right-click the file in Explorer and select the "Properties > General [tab]". If an "Unblock" checkbox is present, enable it and select "OK". (This checkbox will appear depending on how the file was downloaded.)
3. Unzip the 2 .targets files from the .zip file.
4. For Visual Studio 2017, copy the .targets files into the following location, overwriting the existing files:
By default the full expanded path for this (for example in a Developer Command Prompt) will be one of the following, depending on Visual Studio edition:
> C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android
> C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android
> C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android
For Visual Studio 2015, copy the files into the following location, overwriting the existing files:
> C:\Program Files (x86)\MSBuild\Xamarin\Android\
Before this change I was able to hit the issue on 5/5 consecutive solution load attempts in Visual Studio 2017 and 2015. After this change, I did _not_ hit this issue on _any_ of 5 consecutive solution load attempts in either version of Visual Studio.
## Background information
This issue is caused by the attempted fix for Bug 57281 where the `GetAdditionalResourcesFromAssemblies` task was re-enabled for "design time" builds to make XAML IntelliSense behave as expected when the active configuration is set to an Android project.
Unfortunately, this bug report demonstrates that the logic added to avoid downloads in the `GetAdditionalResourcesFromAssemblies` task was not by itself sufficient to avoid hangs in that task during the design time build.
Even after removing the Android Project from this solution, it still freezes my Visual Studio 2017 version 15.5 Preview 1.0
> Even after removing the Android Project from this solution, it still freezes
> my Visual Studio 2017 version 15.5 Preview 1.0
There is a different issue under investigation in the Visual Studio 2017 version 15.5 Preview version that is unrelated to this `GetAdditionalResourcesFromAssemblies` issue:
(The call stack in that case is in "IdbClient" rather than "GetAdditionalResourcesFromAssemblies".)
Recategorizing this bug to Android - MSBuild as this is a fault with design-time builds in VS 2017.
This has been reverted in 15.4 SR2 based on the following PR:
Thus I am marking this as RESOLVED - FIXED for the time being. It still will need to be tested on d15-5 and master. In this case, new bugs should be opened up after verification testing.