Bug 36237 - If multiple mdb are generated at same time (i.e. two android executables), it results in IOException
Summary: If multiple mdb are generated at same time (i.e. two android executables), it...
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: General ()
Version: 4.0.0 (C6)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-11-25 02:38 UTC by Virgile Bello
Modified: 2015-12-17 18:27 UTC (History)
4 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 Virgile Bello 2015-11-25 02:38:33 UTC
If two projects are built together and Output Dir is the same directory, the .mdb generation fails because both tries to copy same file at the same time during _CopyMdbFiles target, CopyMdbTask (it makes build totally fail, as it doesn't seem to recover properly from errors).

Build log:

Xamarin.Android.Common.targets(1462,2): error MSB4018: System.IO.IOException: The process cannot access the file 'C:\DEV\paradox2\Bin\Android-OpenGLES\SiliconStudio.Core.dllSiliconStudio.Core.dll.mdb' because it is being used by another process.
Xamarin.Android.Common.targets(1462,2): error MSB4018:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
Xamarin.Android.Common.targets(1462,2): error MSB4018:    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
Xamarin.Android.Common.targets(1462,2): error MSB4018:    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
Xamarin.Android.Common.targets(1462,2): error MSB4018:    at Xamarin.Android.Tools.Files.HashFile(String filename, HashAlgorithm hashAlg)
Xamarin.Android.Common.targets(1462,2): error MSB4018:    at Xamarin.Android.Tools.Files.HashFile(String filename)
Xamarin.Android.Common.targets(1462,2): error MSB4018:    at Xamarin.Android.Tools.Files.HasFileChanged(String source, String destination)
Xamarin.Android.Common.targets(1462,2): error MSB4018:    at Xamarin.Android.Tools.Files.CopyIfChanged(String source, String destination)
Xamarin.Android.Common.targets(1462,2): error MSB4018:    at Xamarin.Android.Tasks.CopyMdbFiles.Execute()
Xamarin.Android.Common.targets(1462,2): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
Xamarin.Android.Common.targets(1462,2): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Comment 1 Virgile Bello 2015-11-25 02:52:18 UTC
Additional remark: can reproduce on both Android and iOS
Comment 2 Virgile Bello 2015-11-25 04:01:33 UTC
Update: it seems to happen even if output directory for the two android executables are different (conflict happens in the source folder of the .dll assembly).

To reproduce:

* Create a solution with 1 shared library and 2 android executable projects.
* Make sure those two android exec projects uses the shared library.
Comment 3 Joaquin Jares 2015-11-25 12:02:50 UTC
@Virgile I'm trying to repro this but I'm not getting the error. I tried two android blank apps, referencing a portable class library. Both have output folder set to ..\bin\debug, which ends up creating a new bin folder in the solution folder. Is that the same case you're using? Or is shared library a shared project? (In shared project there is no mdb for the libraries, so there shouldn't be an issue there).

Also, can someone from logica verify?

Comment 4 Virgile Bello 2015-11-25 22:11:44 UTC
Right, I can't seem to reproduce it with those 3 empty projects, sorry for the wrong instructions.

I will try to check what differ between it and my bigger case (could just be something like assembly size => longer to generate PDB?), and hopefully generate a project exhibiting the issue I could share with you.
Comment 5 Joaquin Jares 2015-11-26 08:57:03 UTC
Agreed, project size may be a factor. I'll try with big images or something like that (which may take some time to include in the jar) to try and make the android take longer to compile. I'll do it right after investigation on your other bug.
Comment 6 xamarin-release-manager 2015-12-17 18:27:42 UTC
Fixed in version (xcode7.1)

Author: Jonathan Pryor
Commit: 2aa3e62108b37f2f50613bcc925902fae9ba46af (xamarin/monodroid)
Included in Commit: 5fdef47b023be2fb2adb6e14ca900dc1b30ce09c (xamarin/XamarinVS)