VS2013 发布 Web 部署任务失败 The file is in use [英] VS2013 publish Web deployment task failed The file is in use

查看:20
本文介绍了VS2013 发布 Web 部署任务失败 The file is in use的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 VS2013 Premium 将站点发布到 Windows Server 2012.除以下文件外,所有文件都可以发布:SqlServerTypesx64msvcr100.dll

I am using VS2013 Premium to publish a site to Windows Server 2012. All files publish ok except these: SqlServerTypesx64msvcr100.dll

SqlServerTypesx64SqlServerSpatial110.dll

SqlServerTypesx64SqlServerSpatial110.dll

SqlServerTypesx86msvcr100.dll

SqlServerTypesx86msvcr100.dll

SqlServerTypesx86SqlServerSpatial110.dll

SqlServerTypesx86SqlServerSpatial110.dll

我尝试发布的上述每个文件都出现此类错误:Web 部署任务失败.(文件msvcr100.dll"正在使用中.了解更多信息:http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.)

I get this kind of errors for each of the above files I tried to publish: Web deployment task failed. (The file 'msvcr100.dll' is in use. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.)

有趣的是,这些文件是第一次发布(当它们不在服务器上时),然后它们不再被覆盖.尝试使用 2 个不同的 Web 服务器.我遵循了这里的指南:http://blogs.msdn.com/b/webdev/archive/2013/10/30/web-publishing-updates-for-app-offline-and-usechecksum.aspx

Interrestingly, these files were published the first time (when they were not on the server), then they are no longer overwritten. Tried with 2 different web servers. I have followed the guide here: http://blogs.msdn.com/b/webdev/archive/2013/10/30/web-publishing-updates-for-app-offline-and-usechecksum.aspx

...但它只是设法使站点脱机(VS 正在放置 app_offline.htm)但发布仍然失败并出现相同的错误.所有其他文件都完美发布.

...But it only managed to put the site offline (VS is placing the app_offline.htm) but publish still fails with the same error. All other files publish perfectly.

有什么想法吗?

推荐答案

您可以在发布期间让您的应用脱机,这有望解除对文件的锁定并允许您更新它.

You can take you app offline during publishing which hopefully should free up the lock on the file and allow you to update it.

不久前在博客中提到了这个.概述的支持在 Azure SDK 和 Visual Studio 更新中提供.我不记得确切的版本,但如果需要我可以找到.在那篇博文前后/之后的任何更新都应该没问题.

I blogged about this a while back. The support outlined was shipped inside of the Azure SDK and Visual Studio Update. I don't remember the exact releases but I can find out if needed. Any update dating around/after that blog post should be fine.

  • VS 2012 + VS 更新/VS 2013 + VS 更新/VS2015
  • MSDeploy v3

注意:如果您从 CI 服务器发布,CI 服务器也将需要上述更新

在 VS 中,当创建 Web 发布配置文件时,对话框中的设置作为以 .pubxml 结尾的文件存储在 PropertiesPublishProfiles 中.注意:还有一个.pubxml.user文件,该文件不应该被修改

In VS when create a Web Publish profile the settings from the dialog are stored in PropertiesPublishProfiles as files that end with .pubxml. Note: there is also a .pubxml.user file, that file should not be modified

要在 .pubxml 文件中使您的应用离线,请添加以下属性.

To take your app offline in the .pubxml file add the following property.

<代码><EnableMSDeployAppOffline>true</EnableMSDeployAppOffline>

在 MSDeploy 端实现的方式是将 app_offline.htm 文件放置在网站/应用程序的根目录中.从那里 asp.net 运行时将检测到并让您的应用程序脱机.因此,如果您的网站/应用程序没有启用 asp.net,则此功能将不起作用.

The way that this has been implemented on the MSDeploy side is that an app_offline.htm file is dropped in the root of the website/app. From there the asp.net runtime will detect that and take your app offline. Because of this if your website/app doesn't have asp.net enabled this function will not work.

这个实现使得应用在发布开始之前可能不会严格离线.首先删除 app_offline.htm 文件,然后 MSDeploy 将开始发布文件.它不会等待 ASP.NET 检测到文件并实际将其脱机.因此,您可能会遇到仍然遇到文件锁定的情况.默认情况下,VS 启用重试,因此应用程序通常会在其中一次重试期间脱机,并且一切正常.在某些情况下,ASP.NET 响应可能需要更长的时间.这有点棘手.

The implementation of this makes it such that the app may not strictly be offline before publish starts. First the app_offline.htm file is dropped, then MSDeploy will start publishing the files. It doesn't wait for ASP.NET to detect the file and actually take it offline. Because of this you may run into cases where you still run into the file lock. By default VS enables retrys so usually the app will go offline during one of the retrys and all is good. In some cases it may take longer for ASP.NET to respond. That is a bit more tricky.

如果您添加了 <EnableMSDeployAppOffline>true</EnableMSDeployAppOffline> 并且您的应用程序没有尽快脱机,那么我建议您在发布开始之前将应用程序脱机.有多种方法可以远程执行此操作,但这取决于您的设置.如果您只有 MSDeploy 访问权限,您可以尝试以下顺序:

In the case that you add <EnableMSDeployAppOffline>true</EnableMSDeployAppOffline> and your app is not getting taken offline soon enough then I suggest that you take the app offline before the publish begins. There are several ways to do this remotely, but that depends on your setup. If you only have MSDeploy access you can try the following sequence:

  1. 使用 msdeploy.exe 通过删除 app_offline.htm 使您的网站脱机
  2. 使用 msdeploy.exe 发布您的应用(_确保同步不会删除 app_offline.htm 文件_)
  3. 稍等片刻
  4. 发布网站
  5. 使用 msdeploy.exe 通过删除 app_offline.htm 使应用上线
  1. Use msdeploy.exe to take your site offline by dropping app_offline.htm
  2. Use msdeploy.exe to publish your app (_make sure the sync doesn't delete the app_offline.htm file_)
  3. Wait some amount of time
  4. Publish the site
  5. Use msdeploy.exe to bring the app online by deleting app_offline.htm

我在 http://sedodream.com/2012/01/08/howtotake yourwebappofflineduringpublishing.aspx.该博客文章中唯一缺少的是等待站点实际离线的延迟.您还可以创建一个直接调用 msdeploy.exe 的脚本,而不是将其集成到项目构建/发布过程中.

I have blogged how you can do this at http://sedodream.com/2012/01/08/howtotakeyourwebappofflineduringpublishing.aspx. The only thing that is missing from that blog post is the delay to wait for the site to actually be taken offline. You can also create a script that just calls msdeploy.exe directly instead of integrating it into the project build/publish process.

这篇关于VS2013 发布 Web 部署任务失败 The file is in use的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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