发布时站点DLL似乎被间歇性锁定 [英] The site DLL seems to be intermittently locked when publishing

查看:176
本文介绍了发布时站点DLL似乎被间歇性锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过VS2017中的发布上下文菜单将.net核心站点部署到Azure,偶尔(大约每3个部署中有1个),我在下面看到错误。

I try to deploy my .net core site to Azure via Publish context menu in VS2017 and occasionally (about 1 in 3 deploys), I get the error below.


Web部署任务失败。 (Web Deploy无法修改目标上的文件
'MyCoreWebSite.dll',因为它已被
外部进程锁定。为了使发布操作成功,
您可能需要重新启动应用程序以释放
锁定,或在下一次
尝试发布时对.Net应用程序使用AppOffline规则处理程序。有关更多信息,请访问:
http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE 。)

然后我会等一下,再试一次,它将起作用。同时,我将运行处理实用程序,以查找锁定DLL的任何内容,但是它永远找不到。

Then I'll literally wait a minute, try again and it will work. Meanwhile, I'll run the handle utility looking for anything locking the DLL and it never finds anything.

这是一个错误还是我缺少简单的东西?

Is this a bug or am I missing something simple?

推荐答案

ASP.NET Core 不支持文件的卷影复制,这意味着ASP.NET Core进程(Kestrel)将保持对这些文件的锁定。您可以解决此问题:

ASP.NET core does not support shadow copying of files, which means that the ASP.NET Core process (Kestrel) will keep locks on those files. You can work around this:


  1. 在发布并提供 app_offline.htm 页之前,之后将其删除。我认为在发布配置文件(< EnableMSDeployAppOffline> true< / EnableMSDeployAppOffline> )中对此有自动支持。但是,您可以根据需要使用自定义部署脚本来实现。在ASP.NET Core 1.x中,我还必须在Startup.cs文件中添加文件监视任务以关闭当前进程。我不知道ASP.NET Core 2.0是否仍然需要它。

  2. 1。的缺点是发布期间您的网站将处于脱机状态。如果您不希望可以使用网站的副本,请执行以下操作:将所有文件复制到子目录(例如 \PREVIOUS ),然后在网络中更改标签。配置,使其指向新子目录中的.exe。现在,根目录中的所有锁都应该消失了。。。发布您的网站,然后再次更改web.config。

  3. 如果您的网站负载均衡,则可以从一台服务器上移走从池中进行更新,并在完成后将其添加回池中。

  1. Provide an app_offline.htm page before publish and remove it afterwards. I think there is automated support for this in the publish profile file ( <EnableMSDeployAppOffline>true</EnableMSDeployAppOffline>). But you can do it with custom deploy scripts if you want. In ASP.NET Core 1.x I had also to add a file watch task in the Startup.cs file to shut down the current process. I don't know if it is still needed for ASP.NET Core 2.0.
  2. The disadvantage with 1. is that your site will be offline during the publish. If you don't want that you can work with a copy of your site: copy all files to a subdirectory (eg. \PREVIOUS), change the tag in web.config as such that it points to the .exe in the new subdirectory. Now all locks in your root directory should be gone... Publish your site and change the web.config again afterwards.
  3. If your website is load balanced you can off course take out one server from the pool, update it and add it back to the pool when done.

这篇关于发布时站点DLL似乎被间歇性锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆