0

I am currently working on a .NET project, and I'm encountering an issue while attempting to perform an IIS reset. Every time I try to execute the reset, I receive an error that hinders the deployment process. The specific error message I'm facing is as follows:

Failed to deploy web package to IIS website.
Error Code: ERROR_FILE_IN_USE
More Information: Web Deploy cannot modify the file 'Lato-Bold.ttf' 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. For further information, please visit: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.
Error count: 1.

I have explored the iText5 library to address this issue but couldn't find a direct method to release the font resource after usage. Below is a snippet from the class where I create fonts for PDF generation:

protected static BaseFont bf = BaseFont.CreateFont(HttpContext.Current.Server.MapPath("/assetsui/Fonts/Lato/") + "Lato-Regular.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
protected static BaseFont bfBold = BaseFont.CreateFont(HttpContext.Current.Server.MapPath("/assetsui/Fonts/Lato/") + "Lato-Bold.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);

It seems that the 'Lato-Bold.ttf' font file is being locked by an external process, which is preventing successful deployment. I would appreciate any suggestions or guidance on how to resolve this issue. Thank you in advance for your assistance.

  • You can try to set **MSDEPLOY_RENAME_LOCKED_FILES=1** refer to this [link](https://www.koskila.net/fixing-the-error-web-deploy-cannot-modify-the-file-on-the-destination-because-it-is-locked-by-an-external-process/) or this [answer](https://stackoverflow.com/a/49280480/20058276). – TengFeiXie May 30 '23 at 06:52
  • The issue is not caused by a file rename. – Umberto Leone May 31 '23 at 15:29
  • Shut down and restart the application pool, then redeploy. – TengFeiXie Jun 01 '23 at 07:33
  • We make many commits per day and deploy to production frequently, and doing it manually would be bothersome. – Umberto Leone Jun 01 '23 at 14:31
  • So if recycling the app pool works, may you can try deploying it to a new app pool. Setting up periodic recycling for application pool in IIS, it will continues to handle requests that it has already received. – TengFeiXie Jun 02 '23 at 09:43

0 Answers0