Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build ASP.NET 5 to Azure websites from Visual Studio Online ERROR_FILE_IN_USE

I created a dummy Hello World ASP.NET 5 (MVC 6) project hosted in Visual Studio Online's Git. I followed the steps described at this document to build and deploy into my Azure Websites.

It took me several attempts as the build failed with errors such as "Unable to restore NuGet package" or inexisting wwwfolder (which I had to commit to source control to have it working) but I got it working and the app is up and running.

The issue I need help with is with the Continuous Integration configuration. In Visual Studio I have selected a CI trigger to build/deploy whenever there is a check-in in my master branch. This triggers the attempt properly but it constantly fails with this error.

Error Code: ERROR_FILE_IN_USE More Information: Web Deploy cannot modify the file 'AspNet.Loader.dll' on the destination because it is locked by an external process. In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt.

How to solve this problem?

Thank you.

PS: Also I don't know why in Azure websites under Deployment I cannot see the log. When I was using a GitHub hook it used to display all the failed/successful deployments.

Usually in Azure under the web app > DEPLOYMENTS

like image 454
diegosasw Avatar asked Aug 19 '15 21:08

diegosasw


People also ask

How do I Publish my Azure web app from Visual Studio?

Create or open an Azure cloud service project in Visual Studio. In Solution Explorer, right-click the project, and, from the context menu, select Convert > Convert to Azure Cloud Service Project. In Solution Explorer, right-click the newly created Azure project, and, from the context menu, select Publish.

How do I Publish my MVC application to Azure?

Publishing the MVC applicationOpen the MVC project's solution in Visual Studio. Right-click the project in the Solution Explorer and select Publish.... Select Microsoft Azure App Service and choose Select Existing. Click Publish.


1 Answers

I ran into the same issue. There are probably more elegant ways of dealing with it if you have multiple deployment slots but for my situation having a minute of downtime during deployment is acceptable.

You can modify the script to use Start-AzureWebsite and Stop-AzureWebsite Note: I added $hostNameIndex as this needs to change if you add domain names. You could then pass this in the Azure Powershell Script Arguments.

    param($websiteName, $packOutput, $hostNameIndex = 1)
    Stop-AzureWebsite -Name $websiteName
    $website = Get-AzureWebsite -Name $websiteName

    # get the scm url to use with MSDeploy.
    # By default this will be the second in the array. Changes when you add custom domain names. 
    # Here I have the default and 2 custom so scm is in 4th position ie. index: 3
    $msdeployurl = $website.EnabledHostNames[$hostNameIndex]

    $publishProperties = @{'WebPublishMethod'='MSDeploy';
                        'MSDeployServiceUrl'=$msdeployurl;
                        'DeployIisAppPath'=$website.Name;
                        'Username'=$website.PublishingUsername;
                        'Password'=$website.PublishingPassword}


    $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
    Start-AzureWebsite -Name $websiteName

Resources:

  1. https://msdn.microsoft.com/en-us/library/azure/dn495288.aspx
  2. https://msdn.microsoft.com/en-us/library/azure/dn495185.aspx
  3. https://msdn.microsoft.com/Library/vs/alm/Build/azure/deploy-aspnet5
like image 76
Devon Burriss Avatar answered Oct 11 '22 11:10

Devon Burriss