aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Web Deploy cannot modify the file on the destination because it is locked by an external process

Open Bluebell-CyrusYung opened this issue 2 years ago • 7 comments

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

  1. Create a new project with .NET 8
  2. Publish it to IIS with Web Deploy
  3. Project is deployed successfully for the first time
  4. Open a browser and go to the website
  5. Modify something in the project
  6. Publish the project to IIS with Web Deploy one more time
  7. The project .dll is locked and cannot be updated, deployment failed

Exceptions (if any)

No response

.NET Version

8

Anything else?

No response

Bluebell-CyrusYung avatar Feb 08 '24 14:02 Bluebell-CyrusYung

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.

martincostello avatar Feb 08 '24 15:02 martincostello

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 image

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: image

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.

Bluebell-CyrusYung avatar Feb 09 '24 14:02 Bluebell-CyrusYung

Is anyone having the same issue? Should we downgrade our projects to .NET 7 before there is a solution?

Bluebell-CyrusYung avatar Feb 20 '24 13:02 Bluebell-CyrusYung

You can rename current dlls, copy new dlls, and recycle app pool.

tohghua avatar Mar 08 '24 09:03 tohghua

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.

Bluebell-CyrusYung avatar Mar 08 '24 09:03 Bluebell-CyrusYung

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.

tohghua avatar Mar 08 '24 09:03 tohghua

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.

Bluebell-CyrusYung avatar Mar 15 '24 15:03 Bluebell-CyrusYung