45

Very often, when I hit Publish in VS13, I get the site to compile but when uploading I get the error saying that a file is busy.

Updating file (MyAzureSite\PrecompiledApp.config).
C:...\v12.0\Web\Microsoft.Web.Publishing.targets(4255,5):
Error ERROR_FILE_IN_USE: Web deployment task failed.
(The file 'PrecompiledApp.config' is in use.
Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.)

When I follow the link provided, it's suggested that I should go for enabling the appOffline rule. "Sure!", I think to myself. But how?! I've googled it, only to get a bunch of hits on the file that's supposed to replace the site while publishing. However, I get no info on how to get rid of my little problem.

I went the easy way and downloaded a publishing profile from my Azure web site and now I'm using it (you know, ALT+B+H).

Right now I resolve the problem by going to the portal for Azure and manually take the site off-line. Then I can publish and after that I take the site on-line. Highly impractical and painfully tedious.

What is causing this and how do I kill it?

Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438

2 Answers2

60

You actually configure it in the publishing profile (.pubxml). Just add the element to the PropertyGroup like this:

<PropertyGroup>
  <EnableMSDeployAppOffline>true</EnableMSDeployAppOffline>
  ...
</PropertyGroup>

More in this MSDN document

Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
AKhooli
  • 1,285
  • 1
  • 13
  • 11
  • It wasn't automatically found by intellisense so I had to type in all the thing by hand. Strange... And I also noticed that the first element (i.e. **) wasn't recognized, neither. It's underlined by blue wave... Comment on that? I've posted [another question on that subject](http://stackoverflow.com/questions/20921790/correct-tags-in-pubxml-not-recognized-by-intellisense). – Konrad Viltersten Jan 04 '14 at 13:46
  • 1
    VS uses MsBuild Schema to validate the file. You may see several warnings but you can ignore them. People were complaining about this [long ago](http://sstjean.blogspot.com/2007/04/visual-studio-warning-element-in.html) – AKhooli Jan 04 '14 at 17:52
  • 8
    sadly, this solution only works when publishing directly from VS; but the continuous deployment doesn't respect the settings either in the .pubxml file or passed in as command line arguments to MSBuild – Matthew Belk Jul 17 '14 at 17:43
  • @MatthewBelk did you ever figure out how to get this working with CI implementation? Having same troubles here... – Paul Brown Feb 18 '15 at 21:33
  • You could try this on CI: http://www.iis.net/learn/publish/deploying-application-packages/taking-an-application-offline-before-publishing – Nils Nov 02 '15 at 14:45
  • 1
    With VS2015 I get an error saying: [publishing profile] *has invalid child element 'EnableMSDeployAppOffline'*. – Ted Nyberg Jan 19 '16 at 22:07
  • How can I use my custom app offline template for this job? – Oğuzhan Topçu Mar 18 '16 at 16:18
  • I'm not sure if it's because of VS2015 or because it's an asp.net core project but this is an invalid element for me -- doesn't show up in intellisense and trying to use it creates an error saying the site can't be found. – Jeroen Vannevel Aug 01 '16 at 14:34
  • 3
    I found this MSBUILD parameter that I've started using for CI. I haven't seen an error since I started using it... /p:EnableMSDeployAppOffline=true – Sam Sep 16 '16 at 13:53
  • 3
    Awesome! Another valuable setting not accessible by the UI. Love it! – iGanja May 20 '19 at 17:55
12

The Azure App Service Deployment Task has a checkbox for this (from version 2.0 onwards), under Additional Deployment Options: Take App Offline. Check that and you should be good to go.

Take Application Offline: Select the option to take the AzureRM Web App offline by placing an app_offline.htm file in the root directory of the Web App before the sync operation begins. The file will be removed after the sync operation completes successfully.

Screenshot: enter image description here

degant
  • 4,861
  • 1
  • 17
  • 29
Andrej Kyselica
  • 846
  • 9
  • 8
  • What is this _New Azure Web App Deployment` component you speak of? Is this in Visual Studio 2015? is this a manual install for VS2015? – Pure.Krome Feb 10 '17 at 08:51
  • On Visual Studio Online web-site in your project go to "Build & Release" at the top, then select "Deploy AzureRM App Service" task on the left panel, on the right panel find and select "Take App Offline" option. – Sergey Feb 21 '17 at 23:14
  • 1
    Is there a way to tell this option which file to use as app_offline.htm? I'd like to style and customize it. Thanks! – trademark Jan 11 '19 at 14:17
  • The link is dead. – Rosdi Kasim Apr 06 '20 at 07:23