1

During deployment on CD server we're first removing complete website from root directory and then adding custom code on top of that through PowerShell script. During this time we're getting below error:

##[error]Cannot remove item E:\Websites\CD_Website\App_Data\MediaCache: The directory is not empty.
##[error]    + CategoryInfo          : WriteError: (227:DirectoryInfo) [Remove-Item], IOException
##[error]    + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
##[error]    + PSComputerName        : WEBSITECDVM01

For successful deployment, we need to manually remove MediaCache folder. Is there any way to remove this folder forcefully through PowerShell script OR any kind of setting need to change for MediaCache folder?

Please suggest.

2
  • Are you trying to remove all contents from the mediacache folder before the deploy? If the website is stopped the pipeline should be able to delete all the contents. – Cristi Vulturar Mar 9 at 9:56
  • @CristiVulturar Not only mediacache folder, we're removing complete website folder and that's where this script failing while removing mediacache folder – Sukhjeevan Mar 10 at 3:57
0

If you are using powershell to delete the files under MediaCache folder you should use these commands to delete the subfiles aswell

Remove-Item -Path "C:\Website\App_Data\MediaCache\*.*" -recurse

The –recurse parameter will allow PowerShell to remove any child items without asking for permission. Additionally, the –force parameter can be added to delete hidden or read-only files.

Remove-Item -Path "C:\Website\App_Data\MediaCache\*.*" -Force

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.