0
votes

I am trying to remove all files and folders in a specific network path location (the tfs build drop folder of one of my builds).

In my post-build script I tried the following lines: (with same results)

$Destination = '\\footfs32\Builds\TestBuildTest'
Get-ChildItem -Path $Destination -Recurse | Remove-Item -force -recurse

Remove-Item \\footfs32\Builds\TestBuildTest -Force -Recurse

Remove-Item "\\footfs32\Builds\TestBuildTest\*" -Force -Recurse 

Remove-Item -LiteralPath "\\footfs32\Builds\TestBuildTest\*" -Force -Recurse 

All included folders are being removed, but when it tries to remove the files in the dir, the following error pops ups:

Remove-Item : Cannot find path '\abctfs32\Builds\TestBuildTest\foo_3.3.17009.3.zip ' because it does not exist.'

Why is this error popping up on files only, while all folders are deleted correctly? This doesn't make any sense to me. And how do I fix it?

2
may be you dont have permission for remove this fileEsperento57
Unfortunately all folders and files were created by the same user (the build server service account) during the previous builds.Jannik
After the build and ps script, could you see those files in the physically build drop folder ?PatrickLu-MSFT
How did you create the zip file with a space in it?Eddie Chen - MSFT

2 Answers

0
votes

According to the error info.Very likely the file had been deleted in your build process.

Some events triggered during your build process, and that file had been deleted. When running the powershell script, those files couldn't be found. The Remove-item command Can not delete a file twice.

Please double check your build definition, build process and drop folder.

0
votes

Please try the following command:

Remove-Item -Path "\\footfs32\Builds\TestBuildTest\*.*" -Force -Recurse