Similar questions have been asked various times, but most answers are old and may only partially apply. This question is specific to using Web Deploy through Azure DevOps/Azure Pipelines using the "Azure App Service Deploy" task, version 3.\*.

> 
> Failed to deploy web package to App Service.
> 
> 
> Try to deploy app service again with Rename locked files option selected.
> 
> 
> Error Code: ERROR\_FILE\_IN\_USE
> 
> 
> More Information: Web Deploy cannot modify the file 'VBCSCompiler.exe' on the destination because it is locked by an external process. In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish
> attempt. Learn more at:
> <http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE>.
> 
> 
> 

There's two recommendations there:

1. Select "Rename locked files" option
2. Restart the application
3. Use the AppOffline rule

Additionally, [the documentation](https://github.com/Microsoft/vsts-tasks/blob/master/Tasks/AzureRmWebAppDeploymentV3/README.md) for the task reiterates recommendations 1 and 3 together.

> 
> For avoiding deployment failure with error code ERROR\_FILE\_IN\_USE, in case of .NET apps targeting Web App on Windows, ensure that 'Rename locked files' and 'Take App Offline' are enabled. For zero downtime deployment use slot swap.
> 
> 
> 

However, these recommendations are already in place.
[![Deployment settings](https://i.stack.imgur.com/nt6Zs.png)](https://i.stack.imgur.com/nt6Zs.png)

All that's left is recommendation 2: restart the service. For many reasons, I rather not have to fall back to this.

Why are 1 and 3 not enough to complete the deployment successfully?