TFS CI created for Azure Web App (Application Service) does not work due to file locking (msvcr100.dll)

Problem

Getting a deployment error while trying to publish to Azure Web App from TSI CI. The file is locked and this prevents the assembly from updating.

Symptoms

  • Manual publishing (publishing Web Deploy from Visual Studio) usually succeeds.
  • Stopping the web application and publishing allows it to succeed, however, it is detrimental to our CI point if we need to stop and start the web application every time.
  • Publishing CI for web and worker roles does not have such a problem, we get it only when publishing in web applications (previously websites, the current term Azure Portal is now Application Support).
  • Only publishing from a CI assembly through TFS is consistently performed this way.

Error

Failed to complete network deployment task. (Web Deploy cannot modify the 'msvcr100.dll' file at the destination because it is blocked by an external process. To enable the publication to work successfully, you can either restart the application to release the lock or use the AppOffline rule handler for .Net applications in the following release attempt. Learn more: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE .)

Information on the link is not very useful.

ERROR_FILE_IN_USE Diagnostics. The target file cannot be overwritten or deleted because it is currently in use. Resolution. Before synchronizing, make sure that the target file is not in use. If you are synchronizing content on a website hosted in IIS 7 or later (using appHostConfig, iisApp, or contentPath), consider disabling the application during synchronization by including the appOffline rule.

Attempt to resolve

Edit

How to disable a web application during publication? deals with disabling the application in EnableMSDeployAppOffline mode - unfortunately, this configuration seems to be supported only when running WebDeploy through Visual Studio (not CI).

+5
source share
2 answers

You can use Web Deploy v3 in CI to deploy your web application.

In Web Deploy V3, we added support for automatically switching to an ASP.Net application offline before publishing to it. This is useful if the user wants their application to not block the file (for example, Sdf SQL CE files that allow only one connection to the file at a time), or if they want visitors to their site to not affect the publication process. When the publishing process, the file App_Offline.htm will be deleted, and the site will be online again.

Or you can add a PowerShell script as shown below to deploy your web application to Azure:

param($websiteName, $packOutput) $website = Get-AzureWebsite -Name $websiteName # get the scm url to use with MSDeploy. By default this will be the second in the array $msdeployurl = $website.EnabledHostNames[1] $publishProperties = @{'WebPublishMethod'='MSDeploy'; 'MSDeployServiceUrl'=$msdeployurl; 'DeployIisAppPath'=$website.Name; 'Username'=$website.PublishingUsername; 'Password'=$website.PublishingPassword} Write-Output "Stopping web app..." Stop-AzureWebsite -Name $websiteName Write-Output "Publishing web app..." $publishScript = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Publish\Scripts\default-publish.ps1" . $publishScript -publishProperties $publishProperties -packOutput $packOutput Write-Output "Starting web app..." Start-AzureWebsite -Name $websiteName 

Link from: https://msdn.microsoft.com/en-us/Library/vs/alm/Build/azure/deploy-aspnet5

+2
source

In the new AzureRM Web App Deployment task, you can disable an application that will prevent this error.

See screenshot for checkbox

enter image description here

0
source

Source: https://habr.com/ru/post/1240136/


All Articles