How to clean up wwwroot folder on the target Azure Websites Windows Server before each deployment in VSTS

imgen picture imgen · Oct 18, 2017 · Viewed 11.2k times · Source

After about a dozen deployments, the wwwroot directory is filled with a lot of files due to active development and deployments. We are using VSTS's Azure App Service Deploy task to deploy to Azure Websites Windows Server for a ASP.NET Web API project, is there a way to clean up the wwwroot directory before deploying to the Avsts pre-deployment clean up?

Answer

Brendan Green picture Brendan Green · Oct 18, 2017

When using the Azure App Service Deploy task, and you are using the Publish using Web Deploy option, there is an additional option to Remove Additional Files at Destination.

enter image description here

If you check this option, the deployment process will remove any files at the destination where there is no corresponding file in the package that is being deployed.

In other words, it'll remove any left over files from a previous deployment that are no longer required.