Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
205 views
in Technique[技术] by (71.8m points)

c# - VS2013 publish Web deployment task failed The file is in use

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

SqlServerTypesx64SqlServerSpatial110.dll

SqlServerTypesx86msvcr100.dll

SqlServerTypesx86SqlServerSpatial110.dll

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.)

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

...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.

Any ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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.

Prerequisites:

  • VS 2012 + VS update / VS 2013 + VS Update / VS2015
  • MSDeploy v3

Note: if you are publishing from a CI server the CI server will need the updates above as well

Edit the publish profile

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

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

<EnableMSDeployAppOffline>true</EnableMSDeployAppOffline>

Notes

ASP.NET Required

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.

Cases where it may not work

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.

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. 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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...