【问题标题】:nuget package restore fails for webapp with custom nuget.config使用自定义 nuget.config 的 webapp 的 nuget 包还原失败
【发布时间】:2017-10-02 17:57:42
【问题描述】:

我正在尝试解决我在为具有自定义包源的 .net core 2.0 webapi 恢复 nuget 包时遇到的问题。

基本上在包含 nuget.config 时,任何 microsoft 软件包都无法安装,因为它似乎忽略了我的 nuget 参考。

我找到了一种解决方法,即删除我的自定义 nuget.config,让构建失败,一旦失败,它将从 nuget.org 下载正确的内容,然后重新添加自定义文件,它将从磁盘中恢复这些 microsoft 包,然后联系以获取我的自定义 nuget 包。

我的 nuget 包配置如下所示:

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="ASPNET Team" value="https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json" />
    <add key="OTL" value="https://www.myget.org/F/{redacted}/api/v3/index.json" />
  </packageSources>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <bindingRedirects>
    <add key="skip" value="False" />
  </bindingRedirects>
  <packageManagement>
    <add key="format" value="0" />
    <add key="disabled" value="False" />
  </packageManagement>
  <disabledPackageSources />
</configuration>

Kudu 的错误是:

An error occurred while sending the request.
    A connection with the server could not be established
  Retrying 'FindPackagesByIdAsync' for source 'https://www.myget.org/F/{redacted}/api/v3/flatcontainer/microsoft.extensions.caching.sqlserver/index.json'.
  An error occurred while sending the request.
    A connection with the server could not be established
  Retrying 'FindPackagesByIdAsync' for source 'https://dotnetmyget.blob.core.windows.net/artifacts/aspnetcore-ci-dev/nuget/v3/flatcontainer/microsoft.extensions.hosting.abstractions/index.json'.
  An error occurred while sending the request.
    A connection with the server could not be established
  Retrying 'FindPackagesByIdAsync' for source 'https://dotnetmyget.blob.core.windows.net/artifacts/aspnetcore-ci-dev/nuget/v3/flatcontainer/microsoft.extensions.caching.sqlserver/index.json'.
  An error occurred while sending the request.
    A connection with the server could not be established
  Retrying 'FindPackagesByIdAsync' for source 'https://dotnetmyget.blob.core.windows.net/artifacts/aspnetcore-ci-dev/nuget/v3/flatcontainer/microsoft.entityframeworkcore.tools/index.json'.
  An error occurred while sending the request.
    A connection with the server could not be established
  Retrying 'FindPackagesByIdAsync' for source 'https://www.myget.org/F/{redacted}/api/v3/flatcontainer/microsoft.extensions.dependencyinjection.abstractions/index.json'.
  An error occurred while sending the request.
    A connection with the server could not be established
  Retrying 'FindPackagesByIdAsync' for source 'https://dotnetmyget.blob.core.windows.net/artifacts/aspnetcore-ci-dev/nuget/v3/flatcontainer/microsoft.extensions.dependencyinjection.abstractions/index.json'.
  An error occurred while sending the request.
    A connection with the server could not be established
  Retrying 'FindPackagesByIdAsync' for source 'https://www.myget.org/F/{redacted}/api/v3/flatcontainer/microsoft.extensions.caching.sqlserver/index.json'.

直接从 Kudu 控制台执行 dotnet 恢复会产生相同的结果。我已经从我的开发机器中提取了 NuGet.config,我知道它成功地恢复了 microsoft 包和自定义包,并尝试使用它,但它仍然失败。

我开始认为它是 azure 中阻止防火墙的出站端口,但是在 webapp 上搜索出站防火墙或代理的一些谷歌搜索并没有取得成果。

【问题讨论】:

  • 你在使用 CI/CD 吗?您是否检查过 Configuring NuGet behavior 以缩小此问题的范围?
  • 我正在使用来自 github 的 CD。当 master 更新时,它会构建。我的 nuget.Config 显然可以正常工作,因为它正在从中访问 URL,但无论如何它都不会连接。

标签: azure azure-web-app-service asp.net-core-2.0 kudu


【解决方案1】:

因此,在研究并与 Kudu 团队和 Nuget 团队打交道后,我们发现 Azure WebApps 在基本层和免费层中的线程数量有限,并且当 nuget 恢复发生时,它以并行异步方式执行并达到线程限制并失败。

要解决此问题,您必须在 dotnet restore 上使用 --disable-parallel 部署自定义部署脚本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-19
    相关资源
    最近更新 更多