Bug 54467 - Deploy continues forever, VS crashes
Summary: Deploy continues forever, VS crashes
Status: VERIFIED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Debugger ()
Version: unspecified
Hardware: PC Windows
: Normal major
Target Milestone: 15.2
Assignee: Joaquin Jares
URL:
: 53602 54966 ()
Depends on:
Blocks:
 
Reported: 2017-04-04 20:01 UTC by Preetham
Modified: 2018-01-23 16:16 UTC (History)
9 users (show)

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


Attachments
Sample project showing part of the problem (405.32 KB, application/x-zip-compressed)
2017-04-04 20:01 UTC, Preetham
Details
Task Manager (35.99 KB, image/png)
2017-04-06 03:05 UTC, Preetham
Details
filelist showing the mdb line repeating itself (42.20 KB, text/plain)
2017-04-06 12:27 UTC, Preetham
Details
Common.targets file (2.67 KB, text/plain)
2017-04-06 16:19 UTC, Preetham
Details
Output from build (4.07 MB, text/plain)
2017-04-06 19:30 UTC, Preetham
Details
Logs during Verification of Fix. (6.95 KB, application/zip)
2017-04-10 13:02 UTC, Prasad Raghorte
Details


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:
Status:
VERIFIED FIXED

Description Preetham 2017-04-04 20:01:32 UTC
Created attachment 21191 [details]
Sample project showing part of the problem

Deploying an Android app appears to go into an infinite loop, resulting in Visual Studio crashing with what I suspect is an out of memory error.

One symptom of the issue is that in FileListAbsolute.txt the .dll.mdb file gets appended over and over again, until the crash. In my solution I can see it over 4000 times in the file.

Happens in both VS 2015 and VS 2017.

I have not been able to create a sample project that recreates this problem exactly, but I am attaching a solution that does deploy to the emulator, but every time you hit the deploy button, 2 new lines get appended to the FileListAbsolute.txt that can be found at:

MdbRepeatBug\A\M\Framework\obj\Debug\Framework.csproj.FileListAbsolute.txt

This bug could be related to bug #54450

Info from Visual Studio:

Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01586

Installed Version: Enterprise

Architecture and Modeling Tools   00322-80000-00000-AA823
Microsoft Architecture and Modeling Tools
    
UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

Visual Basic 2015   00322-80000-00000-AA823
Microsoft Visual Basic 2015

Visual C# 2015   00322-80000-00000-AA823
Microsoft Visual C# 2015

Visual C++ 2015   00322-80000-00000-AA823
Microsoft Visual C++ 2015

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

Common Azure Tools   1.8
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JetBrains ReSharper Ultimate 2017.1    Build 108.0.20170402.75312
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2017 JetBrains, Inc.

Merq   1.1.14-alpha (21c13c9)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

Mono Debugging for Visual Studio   Mono.Debugging.VisualStudio
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   3.4.4
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

TypeScript   1.8.36.0
TypeScript tools for Visual Studio

Xamarin   4.3.0.795 (aece090)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   7.1.0.43 (3a62f1e)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS   10.6.0.9 (a05f40e)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 1 Preetham 2017-04-06 02:16:41 UTC
Checked with 15.1 released today on VS2017 and the issue persists. I can't build my solution, as the build never completes.
Comment 2 Preetham 2017-04-06 03:05:54 UTC
Created attachment 21231 [details]
Task Manager

Attaching a snapshot of my Task Manager, showing the MSBuild task processes running. It shows the large amount of memory each build process is consuming, while not completing.
Comment 3 Preetham 2017-04-06 12:27:51 UTC
Created attachment 21261 [details]
filelist showing the mdb line repeating itself

I let the build run all night, and it did complete, but in the filelistAbsolute.txt I found the mdb file to contain the mdb file listed over 50,000 times! I am attaching the file if just to show how bad the issue is.
Comment 4 Daniel Cazzulino 2017-04-06 15:49:56 UTC
Hi Preetham, sorry to hear that!

Could you try the following workaround just to verify that that's the root cause?

For VS2017:
Edit the C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Microsoft.Common.Targets\ImportAfter\Xamarin.Common.targets


For VS2015:
Edit the C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.Targets\ImportAfter\Xamarin.Common.targets

(you'll need to be an administrator to edit either one)

In the GetBuiltProjectOutputRecursive, plz comment or delete this entire 

<WriteLinesToFile File="$(IntermediateOutputPath)$(CleanFile)"
                  Lines="@(BuiltProjectOutputGroupKeyOutput -> '%(FullPath).mdb');@(BuiltProjectOutputGroupKeyOutput -> '%(FinalOutputPath).mdb')" 
                  Overwrite="false" 
                  ContinueOnError="WarnAndContinue" />
Comment 5 Preetham 2017-04-06 16:19:18 UTC
Created attachment 21275 [details]
Common.targets file

Daniel, that has not fixed the issue. I still see a large number of entries being added to the file. I am currently running a build and have gone past 7000 entries.

I am attaching the file Xamarin.Common.targets file from this location:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Microsoft.Common.Targets\ImportAfter\Xamarin.Common.targets

I have cleaned out the project before the build, and used git clean -dxf to remove any caches that might have existed in my solution folder.
Comment 6 Preetham 2017-04-06 16:20:16 UTC
I am using VS 2017 to compile by solution.
Comment 7 Preetham 2017-04-06 16:26:11 UTC
When I cancel the build, I do see hundreds of the following lines:

96>C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets(38,3): warning MSB3491: Could not write lines to file "obj\Debug\Framework.csproj.FileListAbsolute.txt". The process cannot access the file 'F:\git\Fb\Ad\MonoDroidHIA2\Framework\obj\Debug\Framework.csproj.FileListAbsolute.txt' because it is being used by another process.
96>C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets(38,3): warning MSB3491: Could not write lines to file "obj\Debug\Framework.csproj.FileListAbsolute.txt". The process cannot access the file 'F:\git\Fb\Ad\MonoDroidHIA2\Framework\obj\Debug\Framework.csproj.FileListAbsolute.txt' because it is being used by another process.
96>C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets(38,3): warning MSB3491: Could not write lines to file "obj\Debug\Framework.csproj.FileListAbsolute.txt". The process cannot access the file 'F:\git\Fb\Ad\MonoDroidHIA2\Framework\obj\Debug\Framework.csproj.FileListAbsolute.txt' because it is being used by another process.
96>C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets(38,3): warning MSB3491: Could not write lines to file "obj\Debug\Framework.csproj.FileListAbsolute.txt". The process cannot access the file 'F:\git\Fb\Ad\MonoDroidHIA2\Framework\obj\Debug\Framework.csproj.FileListAbsolute.txt' because it is being used by another process.
96>C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets(38,3): warning MSB3491: Could not write lines to file "obj\Debug\Hia.csproj.FileListAbsolute.txt". The process cannot access the file 'F:\git\Fb\Ad\MonoDroidHIA2\Hia\obj\Debug\Hia.csproj.FileListAbsolute.txt' because it is being used by another process.
96>C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets(38,3): warning MSB3491: Could not write lines to file "obj\Debug\Framework.csproj.FileListAbsolute.txt". The process cannot access the file 'F:\git\Fb\Ad\MonoDroidHIA2\Framework\obj\Debug\Framework.csproj.FileListAbsolute.txt' because it is being used by another process.
96>C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets(38,3): warning MSB3491: Could not write lines to file "obj\Debug\Hia.csproj.FileListAbsolute.txt". The process cannot access the file 'F:\git\Fb\Ad\MonoDroidHIA2\Hia\obj\Debug\Hia.csproj.FileListAbsolute.txt' because it is being used by another process.
96>C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets(38,3): warning MSB3491: Could not write lines to file "obj\Debug\Framework.csproj.FileListAbsolute.txt". The process cannot access the file 'F:\git\Fb\Ad\MonoDroidHIA2\Framework\obj\Debug\Framework.csproj.FileListAbsolute.txt' because it is being used by another process.
96>C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets(38,3): warning MSB3491: Could not write lines to file "obj\Debug\Framework.csproj.FileListAbsolute.txt". The process cannot access the file 'F:\git\Fb\Ad\MonoDroidHIA2\Framework\obj\Debug\Framework.csproj.FileListAbsolute.txt' because it is being used by another process.
96>C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets(38,3): warning MSB3491: Could not write lines to file "obj\Debug\Hia.csproj.FileListAbsolute.txt". The process cannot access the file 'F:\git\Fb\Ad\MonoDroidHIA2\Hia\obj\Debug\Hia.csproj.FileListAbsolute.txt' because it is being used by another process.
96>C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets(38,3): warning MSB3491: Could not write lines to file "obj\Debug\Hia.csproj.FileListAbsolute.txt". The process cannot access the file 'F:\git\Fb\Ad\MonoDroidHIA2\Hia\obj\Debug\Hia.csproj.FileListAbsolute.txt' because it is being used by another process.
96>C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets(38,3): warning MSB3491: Could not write lines to file "obj\Debug\Framework.csproj.FileListAbsolute.txt". The process cannot access the file 'F:\git\Fb\Ad\MonoDroidHIA2\Framework\obj\Debug\Framework.csproj.FileListAbsolute.txt' because it is being used by another process.
96>C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets(38,3): warning MSB3491: Could not write lines to file "obj\Debug\Framework.csproj.FileListAbsolute.txt". The process cannot access the file 'F:\git\Fb\Ad\MonoDroidHIA2\Framework\obj\Debug\Framework.csproj.FileListAbsolute.txt' because it is being used by another process.
96>C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets(38,3): warning MSB3491: Could not write lines to file "obj\Debug\Hia.csproj.FileListAbsolute.txt". The process cannot access the file 'F:\git\Fb\Ad\MonoDroidHIA2\Hia\obj\Debug\Hia.csproj.FileListAbsolute.txt' because it is being used by another process.
Comment 8 Daniel Cazzulino 2017-04-06 16:46:49 UTC
That tells me the build is still trying to write to that file, so VS either didn't refresh the target for the project (try closing/reopening the sln), or the change was made to a target that isn't the one being used.

The path you have: C:\Program Files (x86)\MSBuild\15.0\ tells me that you have/had an old-ish version of Xamarin installed as an MSI from before VS2017 RTM (actually, prior to VS2017 RC4), since that folder shouldn't exist at all.

Please nuke the Xamarin folder inside that, as well as that Xamarin.Common.targets you see loading from there.

Let me know if that fixes the issue for you (providing the other .targets, inside the VS install directory MSBuild, is updated).
Comment 9 Preetham 2017-04-06 18:11:32 UTC
Removing the old folder and the target file resulted in the symptom going away, i.e., the writing of the mdb entry into the filelist.txt. The problem still appears to exist though, as my build has been going for 15 minutes, and is not showing any signs of completing.

Is there anything I can give you that will help you diagnose this better?
Comment 10 Daniel Cazzulino 2017-04-06 18:20:25 UTC
You may be downloading the big Google deps for the first time. Did you have a successful build before? Have you changed your API levels or target framework recently?

Can you run the build from the command line (you can use /t:Install to install the app on the device after build), which will show better progress in the console? (this is a known VS issue that's going to be fixed by the project system at some point).
Comment 11 Preetham 2017-04-06 18:38:27 UTC
Yes, I have had successful builds before. I had one last night when I let it run overnight. My problem started when I ran a Visual Studio update on Monday. I have another member on my team that who has not updated Visual Studio 2017, and is able to build fine.

My build is still running, I am pretty sure all my dependencies are downloaded, because all my NuGet packages should be cached right now.

In my task manager I can see 11 msbuild processes running, each consuming roughly 700 MB of memory, and the build has been running for over half an hour. I have now cancelled the build and will attempt one from the command line.
Comment 12 Preetham 2017-04-06 19:30:33 UTC
Created attachment 21279 [details]
Output from build

I tried to build with /v:d with redirected output, but quickly crossed 50MB for the file. I am attaching a file with /v:n. I waited till the log got to about 4MB and then force stopped the build.
Comment 13 Daniel Cazzulino 2017-04-06 21:23:55 UTC
ok, I see several unnecessary build steps happening :(

i.e.:

AndroidApp.csproj
  Starkey.Programming.Communication.csproj
  xf.Logger.Factory.Android.csproj
    xF.Common.Android.csproj
  xF.Bluetooth.Android.csproj
    Starkey.Programmers.Android.BLE.csproj
      Starkey.Programming.Communication.csproj
    Starkey.Programming.Communication.csproj
    xF.Common.Android.csproj
  xF.Common.Android.csproj
  xF.Data.Android.csproj
    xF.Common.Android.csproj
  xF.Firebase.Factory.Android.csproj
    xF.Firebase.Android.csproj
  xF.Logic.Android.csproj
    xF.Bluetooth.Android.csproj
      Starkey.Programmers.Android.BLE.csproj
        Starkey.Programming.Communication.csproj
      Starkey.Programming.Communication.csproj
      xF.Common.Android.csproj
    xF.Common.Android.csproj
      xF.Data.Android.csproj
        xF.Common.Android.csproj


Most of those have already been retrieved before.

Could you update the same Xamarin.Common.targets' GetBuiltProjectOutputRecursive contains the following to nodes instead of the current ones?

		<ItemGroup>
			<_GetBuiltOutputProject Include="@(_MSBuildProjectReferenceExistent)"
									Condition="$(_BuiltProjectOutputs.Contains('%(_MSBuildProjectReferenceExistent.FullPath)')) == 'false'" />
		</ItemGroup>

		<PropertyGroup>
			<!-- Add all the top-level projects that will be added by the @(BuiltProjectOutputGroupKeyOutput) further below -->
			<_BuiltProjectOutputs>$(_BuiltProjectOutputs)|$(MSBuildProjectFullPath)|@(_MSBuildProjectReferenceExistent->'%(FullPath)', '|')</_BuiltProjectOutputs>
		</PropertyGroup>



That's a fix for another issue that affects NETStandard project to project references, that we're tracking for 15.2.
Comment 14 Preetham 2017-04-06 22:41:43 UTC
This appears to fix it! My build and deploy works with the change mentioned above.
Comment 15 Daniel Cazzulino 2017-04-08 16:46:05 UTC
Awesome! 

I'll resolve as fixed and it will ship in the 15.2 Visual Studio update.


Thanks for reporting!
Comment 16 Prasad Raghorte 2017-04-10 13:02:05 UTC
Created attachment 21400 [details]
Logs during Verification of Fix.

Bug verified on following configuration:
• Windows 10 Pro
• Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3
• Xamarin   4.5.0.79 (69e356e)
• Xamarin.Android   7.3.0.2 (a67d423)
• Xamarin.iOS   10.10.0.4 (9245c1c)

It is fixed and working as expected. Hence marking it as verified.
Comment 17 Borisov 2017-04-11 06:02:49 UTC
*** Bug 54966 has been marked as a duplicate of this bug. ***
Comment 18 pat 2017-05-25 11:57:41 UTC
I am having a similar issue i.e. Build runs forever and output is full of 

>Could not write lines to file "obj\Debug\MvvmCross.Platform.csproj.FileListAbsolute.txt". The process cannot access the file 'C:\Projects\MVVMCross\MvvmCross\Platform\Platform\obj\Debug\MvvmCross.Platform.csproj.FileListAbsolute.txt' because it is being used by another process.

I read the comment 

"Could you update the same Xamarin.Common.targets' GetBuiltProjectOutputRecursive contains the following to nodes instead of the current ones?"

But did not quite understand it as it seems to missing words after "..GetBuiltProjectOutputRecursive' and before "contains" but perhaps I have read it incorrectly

FWIW our C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.CommonTargets only contains "_CleanMdbFiles"

Looking in C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.Targets\ImportAfter\Xamarin.Common.targets (note MSBUILD folder) there is much more but like i said I do not understand your comment

I am using VS2017 and Xamarin 4.5.0.443
Comment 19 Preetham 2017-05-25 12:32:02 UTC
The file has changed since I submitted this bug, and no longer contains the entries that were modified in steps above. The issue does not occur anymore for me, but I did run into aothern issue along the way, which was that it was picking up a different Xamarin.Common.targets.

I fixed it by looking through the build output, which prints the location of the targets file its actually using and deleting it or moving it. After that Xamarin started picking the right targets file and the issue no longer occurred.

FWIW I still get a bunch of 'it is being used by another proccess' errors, but those tend to be on dlls, and rebuilding a couple of times solves the problem temporarily, so I live with it.
Comment 20 pat 2017-05-25 12:37:59 UTC
"so I live with it." :-) Forget Monkey's there should be Xamarin stickers with that phrase on them
Comment 21 pat 2017-05-25 12:59:49 UTC
I cannot see any mention of which .targets VS17 is using
Comment 22 Preetham 2017-05-25 15:39:05 UTC
It is true that we live with a fair amount of Xamarin quirks! :) Have you changed the build log verbosity? You should see something like I pasted in Comment 7. 

96>C:\Program Files (x86)\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets(38,3): warning MSB3491: Could not write lines to file "obj\Debug\Framework.csproj.FileListAbsolute.txt". The process cannot access the file 'F:\git\Fb\Ad\MonoDroidHIA2\Framework\obj\Debug\Framework.csproj.FileListAbsolute.txt' because it is being used by another process.

You can see the location of the .targets file in that log statement.
Comment 23 pat 2017-05-25 15:43:41 UTC
I swicthed to Diagnostic mode and found it. I have renamed that targets file and will see how that goes
Comment 24 Adrian Alonso 2017-06-21 19:41:11 UTC
*** Bug 53602 has been marked as a duplicate of this bug. ***
Comment 25 smorsi27 2018-01-23 16:16:45 UTC
I'm having the same issue but with a Xamarin.Forms UWP app. Should I make a new bug ticket and add the logs?