从 Visual Studio 在线构建 ASP.NET 5 个到 Azure 网站 ERROR_FILE_IN_USE

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

我在 Visual Studio Online 的 Git 中创建了一个虚拟的 Hello World ASP.NET 5 (MVC 6) 项目。 我按照 this document 中描述的步骤构建并部署到我的 Azure 网站。

我尝试了几次,因为构建失败并出现错误,例如 "Unable to restore NuGet package" 或不存在的 wwwfolder(我必须提交源代码管理才能让它工作)但我让它工作并且应用程序启动了和 运行.

我需要帮助的问题是持续集成配置。在 Visual Studio 中,我选择了一个 CI 触发器来 build/deploy 每当我的 master 分支中有签入时。 这会正确触发尝试,但它会不断失败并出现此错误。

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.

如何解决这个问题?

谢谢。

PS: 另外我不知道为什么在 Deployment 下的 Azure 网站上看不到日志。当我使用 GitHub 挂钩时,它用于显示所有 failed/successful 部署。

通常在 Azure 中的 Web 应用 > 部署

我运行进入同样的问题。如果您有多个部署槽,可能有更优雅的处理方式,但对于我的情况,在部署期间有一分钟的停机时间是可以接受的。

您可以修改脚本以使用 Start-AzureWebsite 和 Stop-AzureWebsite 注意:我添加了 $hostNameIndex,因为如果您添加域名,这需要更改。然后,您可以在 Azure Powershell 脚本参数中传递它。

    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

资源:

  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