Bug 47006 - Random "Collection was modified" when running a command line build
Summary: Random "Collection was modified" when running a command line build
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: XMA ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: 4.4.0 (C10)
Assignee: Bugzilla
Depends on:
Reported: 2016-11-15 16:50 UTC by Jerome Laban
Modified: 2017-07-20 13:21 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jerome Laban 2016-11-15 16:50:29 UTC
When running a command line build to generate an iOS package, the following error randomly fails the build:

2016-11-11T20:37:39.1261271Z        _SayHello:
2016-11-11T20:37:39.1261271Z          Connecting to Mac server XXXXX.local...
2016-11-11T20:37:39.1573776Z          Starting connection to Mac XXXXX.local...
2016-11-11T20:37:41.5480019Z          Starting Broker in port 59827...
2016-11-11T20:37:42.2511245Z          Uploading 'app.plist' (1/1 KB) 100.00%...
2016-11-11T20:37:45.0636277Z          Connection successfully established with the Mac XXXXX.local:59827
2016-11-11T20:37:45.1266892Z ##[error]C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(63,5): Error : Collection was modified; enumeration operation may not execute.
2016-11-11T20:37:45.1266892Z      3>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(63,5): error : Collection was modified; enumeration operation may not execute.

I do not have a stack trace yet, I'll post it when I'll get it.
Comment 1 mag@xamarin.com 2017-01-02 13:51:59 UTC
Moving to future release by now, at least until we can make more research and get more information about the issue.
Comment 2 Jerome Laban 2017-01-09 13:25:24 UTC
If I were to guess, I'd say that it is related to parallel builds in a solution, caused by the fact that iOS "Hello" targets are executed in android builds, for some reason.

I see this happening in a solution that has both android and iOS library and executables.
Comment 3 mag@xamarin.com 2017-01-09 13:44:18 UTC
Thanks Jerome. Could you provide the exact command line that you are using to build the  solution and get the repro?

Also many fixes around iOS builds, specially around the connection handling to the Mac, has been made so that could fix this issue. I would like to test those changes as much similar as possible to your case, so I can see if it's still reproducible.

Comment 4 Jerome Laban 2017-01-09 13:49:11 UTC
Thanks Mauro, it's actually ran from a msbuild target which is inside a msbuild project file, which is itself ran from a VSO agent task.

The failing target in question looks like this:

	RebaseOutputs="false" />
Comment 5 mag@xamarin.com 2017-01-09 18:17:57 UTC
Thanks Jerome. Although I couldn't get a repro on my machine, I introduced many changes  and fixes around iOS build process, specially related to Mac Connection handling. These changes will be available from Xamarin cycle10 release.

Marking the bug as Resolved and assigning to QA for testing for cycle10. This should be tested on master branch from commit 24c2eb75f5956179d09c7a3fb9baf9579bd8255e
Comment 6 Jerome Laban 2017-07-20 13:21:54 UTC
Hi Maq,

This specific issue is still present using Xamarin for VS

Here's the new log:

2017-07-20T07:01:04.3681507Z _SayHello:
2017-07-20T07:01:04.3681507Z   Connecting to Mac server my-server.local...
2017-07-20T07:01:04.4306534Z   Starting connection to Mac my-server.local...
2017-07-20T07:01:10.9305703Z   Starting Broker in port 59549...
2017-07-20T07:01:15.9304982Z   Connection successfully established with the Mac my-server.local:59549
2017-07-20T07:01:16.0867450Z ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(63,5): Error : Collection was modified; enumeration operation may not execute.