When I attempt to deploy to IIS, I consistently encounter a 'file in use' error. I've tried using IIS Manage and Deploy tasks, Copy Files tasks, as well as deleting the 'web.config' file before deployment, but I still face the same issue after some time.
Is there a script or method I can utilize to copy files or deploy to IIS without encountering this error?
You can try the following ways to resolve this issue:
Directly restart the app pool (the target deployment machine). This will kill the process which is using the affected file.
Enable Application Offline for your app.
You can reference the docs "Taking Web Applications Offline with Web Deploy" to configure the publish settings of your app.
If you use the IIS web app deploy task in Azure Pipelines to deploy your app. This task has provided an option (Take App Offline) to enable Application Offline.