对于具有自定义nuget.config的webapp,nuget包还原失败

e5nqia27  于 2021-06-20  发布在  Kudu
关注(0)|答案(1)|浏览(409)

我正在尝试修复为具有自定义包源的.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是没有成效的。

bhmjp9jg

bhmjp9jg1#

因此,在研究和处理kudu团队和nuget团队之后,我们发现azure webapps在基本层和免费层中的线程数量有限,当nuget恢复发生时,它以并行异步方式执行,并且达到线程限制并失败。
要修复此问题,必须在dotnet还原上使用--disable parallel部署自定义部署脚本。

相关问题