3

I am running an onsite TFS 2017 Build Server.

As part of my process, I delete all existing files in a target folder (using the Delete Files Utility).

This works almost every time, however, some sort of permission gets messed up on a file and this process is unable to delete it. Manually deleting the file from Explorer fixes things, but I would like to be able to delete files automatically using my build process.

I have checked and the TFS Service Account has has full rights to the file.

Here is the error

##[section]Starting: Clean Files 
==============================================================================
Task         : Delete Files
Description  : Delete files or folders. (The minimatch patterns will only match file paths, not folder paths)
Version      : 1.1.3
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=722333)
==============================================================================
##[error]Error: Failed rmRF: EPERM: operation not permitted, unlink 'C:\Web\Nodes\hercules\Content\member-int.buzz\Content\Files\181007DF9C61D440A64FE881E76E727DFFD702-THUMB.png'
##[error]Error: Failed rmRF: EPERM: operation not permitted, unlink 'C:\Web\Nodes\hercules\Content\member-int.buzz\Content\Files\181007DF9C61D440A64FE881E76E727DFFD702.jpg'
rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content\Files/181007DF9C61D440A64FE881E76E727DFFD702-THUMB.png
rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content\Files/181007DF9C61D440A64FE881E76E727DFFD702-THUMB.png
rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content\Files/181007DF9C61D440A64FE881E76E727DFFD702.jpg
rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content\Files/181007DF9C61D440A64FE881E76E727DFFD702-THUMB.png 
rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content\Files/181007DF9C61D440A64FE881E76E727DFFD702.jpg
rm: could not remove directory (code ENOTEMPTY): C:\Web\Nodes\hercules\Content\member-int.buzz\Content\Files

##[error]Error: Failed rmRF: rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content\Files/181007DF9C61D440A64FE881E76E727DFFD702-THUMB.png
rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content\Files/181007DF9C61D440A64FE881E76E727DFFD702.jpg
rm: could not remove directory (code ENOTEMPTY): C:\Web\Nodes\hercules\Content\member-int.buzz\Content\Files
rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content/Files/181007DF9C61D440A64FE881E76E727DFFD702-THUMB.png
rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content/Files/181007DF9C61D440A64FE881E76E727DFFD702-THUMB.png
rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content/Files/181007DF9C61D440A64FE881E76E727DFFD702.jpg
rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content/Files/181007DF9C61D440A64FE881E76E727DFFD702-THUMB.png
rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content/Files/181007DF9C61D440A64FE881E76E727DFFD702.jpg
rm: could not remove directory (code ENOTEMPTY): C:\Web\Nodes\hercules\Content\member-int.buzz\Content/Files
rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content/Files/181007DF9C61D440A64FE881E76E727DFFD702-THUMB.png
rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content/Files/181007DF9C61D440A64FE881E76E727DFFD702.jpg
rm: could not remove directory (code ENOTEMPTY): C:\Web\Nodes\hercules\Content\member-int.buzz\Content/Files
rm: could not remove directory (code ENOTEMPTY): C:\Web\Nodes\hercules\Content\member-int.buzz\Content
##[error]Error: Failed rmRF: rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content/Files/181007DF9C61D440A64FE881E76E727DFFD702-THUMB.png
rm: could not remove file (code EPERM): C:\Web\Nodes\hercules\Content\member-int.buzz\Content/Files/181007DF9C61D440A64FE881E76E727DFFD702.jpg
rm: could not remove directory (code ENOTEMPTY): C:\Web\Nodes\hercules\Content\member-int.buzz\Content/Files
rm: could not remove directory (code ENOTEMPTY): C:\Web\Nodes\hercules\Content\member-int.buzz\Content
##[error]Couldn't delete one or more files
##[section]Finishing: Clean Files

It's not always the same file that gets messed up.

7
  • The files that can't be deleted are probably in use. Do you check if the files you are trying to delete are in use?
    – tukan
    Commented Oct 28, 2018 at 7:38
  • EPERM means the file is marked immutable or append-only. Can you please share your build definition and the source folder config of this task?
    – Chun Liu
    Commented Oct 28, 2018 at 13:48
  • Hi @tukan - how would I check if they are in use?
    – William
    Commented Oct 30, 2018 at 1:44
  • 1
    I would try Process Explorer. Did you try to disable your antivirus or even better add a exclusion folder to your antivirus and test it? That could help.
    – tukan
    Commented Oct 30, 2018 at 17:33
  • It's usually a folder called FileManagerTemp btw
    – William
    Commented Nov 2, 2018 at 6:51

0

You must log in to answer this question.

Browse other questions tagged .