【问题标题】:Build ASP.NET 5 to Azure websites from Visual Studio Online ERROR_FILE_IN_USE从 Visual Studio Online 将 ASP.NET 5 构建到 Azure 网站 ERROR_FILE_IN_USE
【发布时间】:2023-03-23 18:05:02
【问题描述】:

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

我尝试了几次,因为构建失败并出现错误,例如“无法恢复 NuGet 包”或不存在的 wwwfolder(我必须提交源代码管理才能使其正常工作),但我让它正常工作并且应用程序已启动并运行。

我需要帮助的问题是持续集成配置。在 Visual Studio 中,只要在我的主分支中签入,我就选择了一个 CI 触发器来构建/部署。 这会正确触发尝试,但它会不断失败并出现此错误。

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:我也不知道为什么在部署下的 Azure 网站中我看不到日志。当我使用 GitHub 挂钩时,它会显示所有失败/成功的部署。

通常在 Azure 下的 web app > DEPLOYMENTS

【问题讨论】:

    标签: azure continuous-integration asp.net-core tfsbuild azure-devops


    【解决方案1】:

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

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

    参数($websiteName,$packOutput,$hostNameIndex = 1) 停止-AzureWebsite -Name $websiteName $website = 获取-AzureWebsite -Name $websiteName # 获取与 MSDeploy 一起使用的 scm url。 # 默认情况下,这将是数组中的第二个。添加自定义域名时的更改。 # 这里我有默认和 2 个自定义,所以 scm 位于第 4 位,即。指数:3 $msdeployurl = $website.EnabledHostNames[$hostNameIndex] $publishProperties = @{'WebPublishMethod'='MSDeploy'; 'MSDeployServiceUrl'=$msdeployurl; 'DeployIisAppPath'=$website.Name; '用户名'=$website.PublishingUsername; '密码'=$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 启动-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

    【讨论】:

    • 谢谢。这是一个很好的解决方法,但我不明白为什么这个部署没有利用新的编译器,只是简单地刷新应用程序而不重新启动它.. :(
    • 我不确定 Roslyn 是否与此有关。使用 Roslyn,我们在工作时在内存中编译人工制品,而不是基于文件的 dll。这里的构建是创建 dll 作为构建工件,然后将它们推送到 Azure。我相信无论如何在进行代码更改时,应用程序池仍会在本地被回收。这里的问题是加载器被锁定,通过停止网站我们强制它放手。希望这有意义吗?也希望它是正确的:)
    • 很好,很有道理。
    猜你喜欢
    • 2015-08-20
    • 1970-01-01
    • 2014-02-08
    • 2018-11-16
    • 2015-10-27
    • 1970-01-01
    • 2020-03-09
    • 2015-04-24
    • 2014-12-20
    相关资源
    最近更新 更多