Web Deploy cannot modify the file on the destination because it is locked by an external process
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
Cannot deploy .NET 8 applications to IIS with Web Deploy. The error message was the project .dll was locked so it could not be updated. I downgraded the project to .NET 6 or .NET 7, both of them didn't have the issue and could be updated successfully.
Expected Behavior
No response
Steps To Reproduce
- Create a new project with .NET 8
- Publish it to IIS with Web Deploy
- Project is deployed successfully for the first time
- Open a browser and go to the website
- Modify something in the project
- Publish the project to IIS with Web Deploy one more time
- The project .dll is locked and cannot be updated, deployment failed
Exceptions (if any)
No response
.NET Version
8
Anything else?
No response
One thing you could try to see if it unlocks you, you could set the MSDEPLOY_RENAME_LOCKED_FILES environment variable to 1 and see if that helps. That's a setting I've used in Azure App Service for a while.
I put the environment variable MSDEPLOY_RENAME_LOCKED_FILES in .pubxml but it's still not working.
The below is how my .pubxml looks like
We didn't expect upgrade to .NET 8 would make our deployment so hard.
We tried to recycle the application pool but it still didn't work, it will wait until the Shutdown Time Limit in IIS which is 90s by default. It seems something is stuck even when there is no pending request like the image below:
The quickest way for us now is to manually kill the w3wp.exe and publish the application. Is anyone having the same issue? This issue happens in all of our IIS servers as long as the applications are .NET 8.
Is anyone having the same issue? Should we downgrade our projects to .NET 7 before there is a solution?
You can rename current dlls, copy new dlls, and recycle app pool.
You can rename current dlls, copy new dlls, and recycle app pool.
Could you please elobrate what are the steps? When files are locked, they cannot be renamed. Recycling app pool does not work as I mentioned it will wait until the Shutdown Time Limit in IIS which is 90s by default. It seems something is stuck even when there is no pending request.
Although dll can't be deleted, it CAN be renamed in my server. You can give it a try.
I also don't know what is suck when recycling, but it doesn't matter if you use rename approach.
Although dll can't be deleted, it CAN be renamed in my server. You can give it a try.
I also don't know what is suck when recycling, but it doesn't matter if you use rename approach.
I did try your approach and it seems the file can be renamed but I didn't do the deployment to try the whole flow. Currently, I downgraded my projects to .NET 7 before the bug is fixed.