【问题标题】:Azure App Service build fails due to error MSB3191: Unable to create directory由于错误 MSB3191,Azure 应用服务构建失败:无法创建目录
【发布时间】:2021-07-30 01:28:30
【问题描述】:

平台:Azure 应用服务

部署:本地 Git

版本: .NET 5

将更新(git 推送到 Azure 中的远程本地 Git).NET 5 Razor Pages 应用程序部署到 Azure 应用程序服务时,KUDU 构建失败并出现以下错误。我可以通过使用Azure Portal中的Console手动删除整个/obj目录来解决问题,然后构建成功。但理想情况下,每次我需要推送更新时都不需要这样做。有没有简单的方法来防止这个错误?

“git push”到远程后终端出错:

remote: RazorCoreGenerate:
remote:   Removing directory "obj\Release\net5.0\Razor\".
remote:   Creating directory "obj\Release\net5.0\Razor\Areas\Identity\Pages\Account\".
remote: D:\Program Files (x86)\dotnet\sdk\5.0.201\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(146,5): error MSB3191: Unable to create directory "obj\Release\net5.0\Razor\Areas\Identity\Pages\Account\". Could not find a part of the path 'obj\Release\net5.0\Razor\Areas\Identity\Pages\Account\'. [D:\home\site\repository\abc.csproj]
remote: Done Building Project "D:\home\site\repository\abc.csproj" (default targets) -- FAILED.
remote:
remote: Build FAILED.
remote:
remote: "D:\home\site\repository\abc.csproj" (default target) (1:7) ->
remote: (RazorCoreGenerate target) ->
remote:   D:\Program Files (x86)\dotnet\sdk\5.0.201\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(146,5): error MSB3191: Unable to create directory "obj\Release\net5.0\Razor\Areas\Identity\Pages\Account\". Could not find a part of the path 'obj\Release\net5.0\Razor\Areas\Identity\Pages\Account\'. [D:\home\site\repository\abc.csproj]
remote:
remote:     0 Warning(s)
remote:     1 Error(s)
remote:
remote: Time Elapsed 00:01:54.09
remote: Failed exitCode=1, command="D:\Program Files (x86)\MSBuilds\16.8.3\MSBuild\Current\Bin\MSBuild.exe" /restore "D:\home\site\repository\abc.csproj" /p:DeployOnBuild=true /p:configuration=Release /p:publishurl="D:\local\Temp\8d9118005db4f8f"
remote: An error has occurred during web site deployment.

(我提前道歉。这是我在 stackoverflow 上发布的第一个问题)

【问题讨论】:

    标签: azure razor msbuild azure-web-app-service .net-5


    【解决方案1】:

    1.检查文件夹权限。

    2.打开cmd 工具为Administrator,然后re-run 你的命令。

    如果在Visual Studio工具中使用命令,还需要以管理员身份运行Visual Studio。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-02
      • 1970-01-01
      • 1970-01-01
      • 2015-02-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多