bruceiow
bruceiow

Reputation: 327

TFS build broken - The directory is not empty on sources directory

I am having a problem with my build (TFS2010). All has been well with this build recently until today where I am now getting an error pretty much as soon as the build starts:

Delete Sources Directory (00:00) The Directory is not empty.

I have looked on the server and I see \builds\1\myproject\sources\ is empty.. there is nothing in there at all! The error hints towards that not being the case, but it is empty for sure.

I wonder if it should not be empty in this case? Can anyone advise me on what course of action I might take on this to get the build running again?

This is the log of the failed build:

Overall Build Process
00:00
Update Build Number
00:00
Create the Drop Location
00:03
Run On Agent (reserved build agent Default Agent - server1)
00:00
Delete Test Results Directory
00:00
Delete Binaries Directory
00:00
Delete Workspace
00:00
Delete Sources Directory
 The directory is not empty.

Many thanks for any help!

Upvotes: 25

Views: 14980

Answers (6)

Debbie A
Debbie A

Reputation: 434

I got this very fast error multiple times one day, and in each case there was another tab or browser where I had my app (that I was trying to build) running. So there was no way for the build to get rid of files in use by the instance of the app running. The worst one I found was trying to do a build in Chrome and I finally found an instance of my app running in Edge. If worst comes to worst, reboot and that worked for me. Reboot kills the app instance you can't find.

Upvotes: 0

Phil Clevy
Phil Clevy

Reputation: 23

For this problem, I just erase the deposit folder of the build that failed on the build server. I did not find anything in the event log. This is valid for those who have chosen to copy the output of the generation into a folder on the build server. My configuration: VS2015 / TFS2015 Build server: Windows Server 2008 R2

Upvotes: 0

Devanathan.S
Devanathan.S

Reputation: 1472

I had come across this issue as one of the deployment folder in the "c:\" was openend. so close the folder and start your build will work. thanks

Upvotes: 5

Chris
Chris

Reputation: 825

Usually a file handle as mentioned above, although if you can't find the culprit deleting the "C:\agent_work\#NumberOfBuildDefinition#" will release this and mean the build can publish again.

This happens as your build definition, has a repository settings of "Clean" set to "true" and "Clean options" set to "Sources" so on every new build it's trying to remove all files from the folder in question.

Upvotes: 0

HostageBrain
HostageBrain

Reputation: 234

except case when there are somebody took handle to subdir or any file in this dir - such error can happens when there are files in directory (or in any subdirectory) which path length > 260 symbols. In such cases you need to delete '\\?\C:\mydir' instead of 'C:\mydir'. About 260 symbols limit you can read here.

Upvotes: 1

James Reed
James Reed

Reputation: 14052

This usually happens if some other process has a handle on the file system. Explorer or a command prompt window is often the culprit.

Upvotes: 48

Related Questions