2
votes

So i have been deploying my website for some days now, suddenly i get a weird error when i try to deploy my website. I do use GIT, so maybe something went wrong there. These errors are kinda hard for me to understand. So i hope someone here can help me.

When i deploy the website, this is the error visual studio returns:

Web deployment task failed. (Web Deploy cannot modify the file 'PraktijkOpdracht.dll' 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.)

And when i look into the temp file where the error get logged. I see this:

15-12-17 22:58:28 System.AggregateException: One or more errors occurred. ---> System.Exception: Publish failed due to build errors. Check the error list for more details. --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass40_0.b__2() at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.d__108.MoveNext() ---> (Inner Exception #0) System.Exception: Publish failed due to build errors. Check the error list for more details.<---

7
It looks like your web application might be in use while during the deployment. Can you try to shut down/ restart your web app and then try again?Ankit Vijay
I usually stop the app before deployment and start the app after deployment is finished (in my CI/CD environments). On production, care should be taken because the app may be serving its pending requests.Khanh TO

7 Answers

2
votes

I've experienced this before as well. I restarted my Web App and was then able to publish. This seemed to be a transient error for us.

2
votes

The key to it is "it is locked by an external process." This kind of error usually can happen when the serviceplan is small dimensioned.

At that time more than one deployment is trying to succeed - before the other could finish.

Best practice to resolve could be :

  • extend the serviceplan
  • ensure to use deployment slots(make use of parallel deploy stages)
1
votes

I faced the same issue and got resolved after selected the checkbox in settings (I selected Publish to Folder)

    1. Delete all existing files prior to publish
    1. Precompile during publishing
    1. Exclude files from the App_Data folder

Thanks

0
votes

Minimize the path of publish folder with project name

Ex:

E:\ABC Project\bin\Release\PublishOutput

Then publish the project.

0
votes

I've experienced the same in both publishing to Azure and local IIS path in my devenv

it was in Visual Studio publishing Settings > File Publish Options and uncheck Precompile during publishing checkbox

0
votes

I know this was posted quite awhile ago, but I experienced this same issue and for me the problem was trying to publish my website to a folder that required administrative rights. Moving to a folder that didn't require administrative rights fixed this for me. Maybe running VS in administrator mode would also help, but I haven't tested that yet. Hopefully this helps someone at some point.

0
votes

My case may be rare but FWIW I had this error/problem and it was due to a recent change to my network password. I was using VPN and Visual Studio was publishing to \server\c$... and until I disconnected from that c$ share and reconnected w/my new credentials I kept getting this VS publish error.