Bug 43738 - Cannot copy files because devenv.exe has them locked
Summary: Cannot copy files because devenv.exe has them locked
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Debugger ()
Version: 4.1.2 (C7SR1)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Joaquin Jares
Depends on:
Reported: 2016-08-25 08:50 UTC by jcaptanis
Modified: 2016-10-10 07:35 UTC (History)
4 users (show)

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

error in ide (35.84 KB, image/png)
2016-08-25 08:50 UTC, jcaptanis
access denied (12.54 KB, image/png)
2016-08-29 03:21 UTC, jcaptanis
xam logs 7days (852.38 KB, application/zip)
2016-08-29 03:21 UTC, jcaptanis
after locking dlls in packages dir -> locked in bin dir (9.54 KB, application/zip)
2016-08-29 06:34 UTC, jcaptanis
happening more, this time locking shared project dll (8.20 KB, application/zip)
2016-08-30 07:19 UTC, jcaptanis

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 jcaptanis 2016-08-25 08:50:37 UTC
Created attachment 17211 [details]
error in ide

This happens to me every couple of hours. I will be debugging (using iOS emulator), stop, make some changes, rebuild and debug and it will fail because it cannot overrite an existing file in the /bin directory. It happens with both Andriod and iOS, and if its iOS, it will be complaining that my files have become out of sync with the mac agent, and i should rebuild. Rebuilding results in "could not copy errors". While Andriod, i just get failed builds with copy not copy "retried 10 times" - andiod its mostly the .mdbs that get locked.

ive noticed various bug reports over the years highlighting this issue, and they are always closed claiming its fixed, but it isnt, and its a massive *** in my workflow. The only way to resolve it is by quiting VS and re-opening. Closing the solution does not work. Sometimes, it will recour within 1 debug session of me restarting, other times, 10. Let me know what else i can do to get you guys more debug information! In windows explorer, it will say "devenv.exe" has the file locked. Usually its the NewtonSoft.Json.dll, but sometimes its the project.dll i am building. In my dir, these are not the first or last files (if that gives u any clues, lol).

This never happens anytime im working on another other project type, including silverlight (urgh). 

My specs VS specs -->

Microsoft Visual Studio Ultimate 2013
Version 12.0.40629.00 Update 5
Microsoft .NET Framework
Version 4.6.01532

Installed Version: Ultimate

Architecture and Modeling Tools   06181-004-0451047-02635
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.

Team Explorer for Visual Studio 2013   06181-004-0451047-02635
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06181-004-0451047-02635
Microsoft Visual Basic 2013

Visual C# 2013   06181-004-0451047-02635
Microsoft Visual C# 2013

Visual C++ 2013   06181-004-0451047-02635
Microsoft Visual C++ 2013

Visual F# 2013   06181-004-0451047-02635
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06181-004-0451047-02635
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06181-004-0451047-02635
Windows Phone SDK 8.0 - ENU

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

ASP.NET and Web Tools   12.5.60612.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Web Apps
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.30612.0
For additional information, visit http://www.asp.net/

AutoT4   1.0
A zero-configuration extension for Visual Studio 2012 which will automatically run your T4 templates at build time.

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

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

Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

Microsoft Azure Tools   2.4
Microsoft Azure Tools for Microsoft Visual Studio 2013 - v2.4.20730.1601

Microsoft Team Foundation Server 2013 Power Tools   12.0
Power Tools that extend the Team Foundation Server integration with Visual Studio.

Microsoft Visual Studio Process Editor   1.0
Process Editor for Microsoft Visual Studio Team Foundation Server

Node.js Tools   1.0.21029.05
Adds support for developing and debugging Node.js apps in Visual Studio

Node.js Tools - Profiling   1.0.21029.05
Profiling support for Node.js projects.

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

Office Developer Tools for Visual Studio 2013 ENU   12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU

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

Silverlight Debug Helper   1.0
Attaches to the correct browser processes for Silverlight debugging automatically. For more information about the Silverlight Debug Helper, see the project page at http://sldebughelper.codeplex.com 

SQL Server Data Tools   12.0.41012.0
Microsoft SQL Server Data Tools

StopOnFirstBuildError   1.0

Stops a solution build immediately after a project has failed to build.


T4 Toolbox
Extends code generation capabilities of Text Templates.

VSColorOutput   2.4
Color output for build and debug windows - http://mike-ward.net/vscoloroutput

Windows Installer XML Toolset   3.8.1128.0
Windows Installer XML Toolset version 3.8.1128.0
Copyright (c) Outercurve Foundation. All rights reserved.

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

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

Xamarin.Android (1cf254d)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS (f37444a)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 2 jcaptanis 2016-08-29 03:21:06 UTC
Created attachment 17230 [details]
access denied
Comment 3 jcaptanis 2016-08-29 03:21:42 UTC
Created attachment 17231 [details]
xam logs 7days
Comment 4 jcaptanis 2016-08-29 03:23:00 UTC
doesnt look like any of those bug reports match my problem. Ive attached the logs as requested.
Comment 5 jcaptanis 2016-08-29 06:24:55 UTC
further to this, for our needs, we also have a process which runs afterbuild, to copy dlls from other projects into the root/packages/our_dependencies folder. We use this approach across about 5 different solutions. At the same rate at which the previously mentioned .dlls get locked, these also get locked and i need to close/open VS to free them so i can deploy a new set of updated dependencies in.

to summaries

(another solution).Build => copys to Xamarin/packages/our_dependeices dir

the .dlls (NOT .mdb) get locked by devenv.exe the same as inside the iphonesimulator/bin folder

Thought this may be another debuging point, as i hazard a guess the same process is locking both these dlls up.
Comment 6 jcaptanis 2016-08-29 06:34:55 UTC
Created attachment 17236 [details]
after locking dlls in packages dir -> locked in bin dir
Comment 7 jcaptanis 2016-08-29 06:35:34 UTC
2>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(3797,5): error MSB3027: Could not copy "C:\svn\RedView Xamarin\packages\RedView Common\RedRain.RedView.Domain.dll" to "bin\Debug\RedRain.RedView.Domain.dll". Exceeded retry count of 10. Failed.
2>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(3797,5): error MSB3021: Unable to copy file "C:\svn\RedView Xamarin\packages\RedView Common\RedRain.RedView.Domain.dll" to "bin\Debug\RedRain.RedView.Domain.dll". The process cannot access the file 'bin\Debug\RedRain.RedView.Domain.dll' because it is being used by another process.
Comment 8 jcaptanis 2016-08-29 06:40:52 UTC
Im just going through one of these frenzies (dlls being locked) now. Im noticing that restarting VS doesnt always let go of the affected file - i need to physically delete the existing file post close of VS, otherwise it may still lock the file apon next open.
Comment 9 jcaptanis 2016-08-30 07:19:09 UTC
Created attachment 17256 [details]
happening more, this time locking shared project dll
Comment 10 jcaptanis 2016-10-10 07:35:14 UTC
Just want to update this to say my problems have completely gone away since the latest release Cycle8 - 4.2.0698. Nice work :)