CoderAnswer - 程序员编程问答

Azure Web App(linux)dotnet核心2.2中的默认部署脚本的权限问题

by @mjh

git azure .net-core nuget azure-web-app-service

在Azure WebApp(linux)中使用dotnet core 2.2中的本地git部署方法,我得到了我猜测默认nuget路径的权限问题。

这是我在bitbucket上的部署管道

- step:
  image: microsoft/dotnet
  name: Deploy DataCore
  script:
    - git subtree split -P data-core -b split
    - git push https://$BACKEND_LOGIN:[email protected]$BACKEND_GITURL split:master --force

这是从远程以及部分日志部分返回的内容:

+ git push https:// $ BACKEND_LOGIN:$ BACKEND_PASSWORD @ $ BACKEND_GITURL split:master --force
remote:部署异步
remote:更新分支'master'。
remote:更新子模块。
remote:为commit id'449e740796'准备部署。
remote:生成部署脚本。
remote:运行部署命令...
remote:处理ASP.NET Core Web Application部署。
remote:.........................
remote:恢复/home/site/repository/data-core.csproj的包...
remote :.
remote:安装NuGet.Frameworks 4.7.0。
remote:/opt/dotnet/2.2.104/sdk/2.2.104/NuGet.targets(114,5):错误:拒绝访问路径'/var/nuget/nuget.frameworks/4.7.0'。 [/home/site/repository/data-core.csproj]
remote:/opt/dotnet/2.2.104/sdk/2.2.104/NuGet.targets(114,5):错误:权限被拒绝[/home/site/repository/data-core.csproj]
remote:网站部署期间发生错误。
remote:dotnet restore失败
remote:App容器将在10秒内重新启动。
remote:部署日志:'https://_NAME_.scm.azurewebsites.net/newui/jsonviewer?view_url=/api/deployments/449e74079667b8ff046c75a45d4e2e251f99e4d0/log'
要https://_NAME_.scm.azurewebsites.net:443/_NAME_.git
   9bfde94..449e740  split -> master

注意这两个错误

remote:安装NuGet.Frameworks 4.7.0。
remote:/opt/dotnet/2.2.104/sdk/2.2.104/NuGet.targets(114,5):错误:拒绝访问路径'/var/nuget/nuget.frameworks/4.7.0'。 [/home/site/repository/data-core.csproj]
remote:/opt/dotnet/2.2.104/sdk/2.2.104/NuGet.targets(114,5):错误:权限被拒绝[/home/site/repository/data-core.csproj]

此WebApp尚未在默认值之外配置,我在其他时间使用过此设置。所以我想知道是否有更新需要我改变一些东西。

这是我的.csproj文件

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
    <RootNamespace>data_core</RootNamespace>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AutoMapper" Version="8.1.0" />
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.1.0" />
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
  </ItemGroup>

</Project>

此处也是完整部署日志

[{"log_time":"2019-05-07T08:41:18.5348434Z","id":"","message":"Command: \"/home/site/deployments/tools/deploy.sh\"","type":0,"details_url":null},{"log_time":"2019-05-07T08:41:18.6366309Z","id":"","message":"Handling ASP.NET Core Web Application deployment.","type":0,"details_url":null},{"log_time":"2019-05-07T08:41:47.6970957Z","id":"","message":"  Restoring packages for /home/site/repository/data-core.csproj...","type":0,"details_url":null},{"log_time":"2019-05-07T08:41:53.3146873Z","id":"","message":"  Installing NuGet.Frameworks 4.7.0.","type":0,"details_url":null},{"log_time":"2019-05-07T08:41:53.3801758Z","id":"","message":"/opt/dotnet/2.2.104/sdk/2.2.104/NuGet.targets(114,5): error : Access to the path '/var/nuget/nuget.frameworks/4.7.0' is denied. [/home/site/repository/data-core.csproj]","type":0,"details_url":null},{"log_time":"2019-05-07T08:41:53.4164253Z","id":"","message#ha​​shtag28 /选择/ DOTNET / 2.2.104 / SDK / 2.2.104 / NuGet.targets(114 ,5):错误:权限被拒绝[/home/site/repository/data-core.csproj] ","type ":0,"details_url ":null},{"log_time":"2019-05-07T08:41:53.5778675Z ","id ":" ","message ":"在网站部署期间发生错误。","type ":0,"details_url ":null},{"log_time":"2019-05-07T08:41:53.6091768Z ","id ":"","message ":"dotnet restore failed ","type ":0,"details_url ":null},{"log_time":"2019-05-07T08:41:53.6748839Z","id":" ","message":" \\ n / opt /Kudu/KuduConsole/Scripts/starter.sh \ "/home/site/deployments/tools/deploy.sh\" ","type ":2,"details_url“:null}]

1个答案

0 by @mjh

似乎这个特定包有问题。它试图写入全局NuGet文件夹,这些文件夹显然是写保护的。

<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />

相关问题