Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not copy. The process cannot access the file because it is being used by another process

I am getting the following error when running my build on Visual Studio Online (using the built-in Build Controller):

C:\Program Files (x86)\MSBuild\14.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (3962): Could not copy "d:\a\src\MySolution\MyProject\Trunk\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.xml" to "..\Build\bin\Release\Microsoft.Data.Edm.xml". Beginning retry 1 in 1000ms. The process cannot access the file '..\Build\bin\Release\Microsoft.Data.Edm.xml' because it is being used by another process.

It is never the same file either but it seems to always be either an xml or dll from the packages folder.

EDIT: I'm not sure if it is worth mentioning, but I do have multiple workspaces and multiple build definitions using this repository.

like image 982
Dave New Avatar asked May 07 '15 14:05

Dave New


People also ask

How do you fix process Cannot access the file because it is being used by another process?

This can happen if the file referenced is open in another program or if a crash occurs while uploading. To resolve it, first make sure that no users have the file open anywhere, then reboot the machine to make sure it is not open as a remnant from a crash.

How do you check if a file is being used by another process in Windows C#?

First check if the file exists (File. Exists) if so try to open for write within try and catch block, if exception is generated then it is used by another process.

Is the process Cannot access the file because another process IIS?

Resolution. To resolve this problem, stop the application that is using port 80, and then start the Web site from IIS Manager. A simple way to see if port 80 is used by other program is to run "netstat -ano" in the command prompt. Find port 80 (Local Address 0.0.


2 Answers

I found the problem. Completely unrelated to the error above.

I went into the msbuild log files and found this:

Failed to produce diagnostics extension's config for MyRole\diagnostics.wadcfgx. Error : Could not find a part of the path 'd:\a\src...\MyRole\diagnostics.wadcfgx'. Done Building Project "d:\a\src...\MyCloudProject.Cloud.ccproj" (Publish target(s)) -- FAILED.

I was missing a file in source control.

I do wonder why this error did not bubble up into my build summary. And where did that initial error come from?

like image 198
Dave New Avatar answered Sep 30 '22 03:09

Dave New


I am using TFS with Using Visual Studio 2013 and have been able to work around this issue by closing all open documents that I want to check-in (seems VS locked itself out) and/or resolving conflicts. The error message is sufficiently vague so as to be useless as to the actual cause of the check-in failure.

Update 02 November 2016:

I'm not sure why VS 2013 and TFS don't play nice together via the Team Explorer Check-in Pending Changes button, but it consistently fails to launch the conflict resolver, a key piece of the check-in process.

The following works for me on VS 2013 and TFS hosted on a SQLServer Express 2014 database: 1. Launch the Source Explorer: Team Explorer tab -> Source Explorer
2. Navigate to your solution repository 3. Then proceed to do the following for each project that you want to check in: a. Right click project b. Check in pending changes c. Resolve conflicts and repeat steps 3a and 3b until no pending changes remain for the project

like image 37
cghore Avatar answered Sep 30 '22 02:09

cghore