我正在运行现场 TFS 2017 Build Server。
作为我的流程的一部分,我删除目标文件夹中的所有现有文件(使用删除文件实用程序)。
这种方法几乎每次都能奏效,但是,如果某个文件的某种权限出现问题,则此过程无法删除它。手动从 Explorer 中删除文件可以解决问题,但我希望能够使用我的构建过程自动删除文件。
我已经检查过并且TFS服务帐户对该文件拥有完全权限。
这是错误
##[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
弄乱的文件并不总是同一个。