簡體   English   中英

VSTS:nuget.exe 失敗並返回代碼:1 包無法恢復

[英]VSTS: nuget.exe failed with return code: 1 Packages failed to restore

我是 Visual Studio 2017 的新手,我正在嘗試使用 Visual Studio Team Services 進行構建。 我收到以下錯誤:

System.AggregateException: One or more errors occurred. ---> NuGet.Protocol.Core.Types.FatalProtocolException: Failed to retrieve information about 'Microsoft.AspNetCore' from remote source 'http://nuget.ohyeah.net/api/v2/FindPackagesById()?id='Microsoft.AspNetCore''. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The remote name could not be resolved: 'nuget.ohyeah.net'

我正在谷歌搜索以確保我知道為什么會發生此錯誤,但還沒有運氣。 可以在此處找到示例堆棧跟蹤: https : //pastebin.com/RiGmd7Cd

可能是什么原因,是因為 Nuget.Config 中的某些設置嗎? 它看起來完全像下面:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
  <disabledPackageSources />
  <packageSources>
    <add key="3rdparty" value="http://nuget.XXX.net/api/v2/" />
    <add key="official" value="http://nuget.XXX.net/api/v2/" />
      <add key="vsts-official" value="https://XXXXXX.pkgs.visualstudio.com/_packaging/Official/nuget/v3/index.json" />
    <!--<add key="local" value="C:\inetpub\wwwroot\Packages" />-->
    <add key="microsoft" value="https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/" />
    <add key="nuget.org" value="" />
  </packageSources>
</configuration>

我堅持這一點,任何幫助將不勝感激。

首先,檢查nuget.ohyeah.net可以從構建代理訪問。

其次,您需要檢查Nuget.config文件是否在包源中包含https://api.nuget.org/v3/index.json ,如果沒有添加的話:

<packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
  1. 項目根文件夾(如果存在)。
  2. 如果在NuGet Restore任務中指定了Nuget配置文件
  3. 構建代理上的構建服務用戶文件夾(%appdata%\\ Nuget)

順便說一句,您提供的代碼不是用於Nuget.Config的,而是NuGet軟件包文件。

看來您已在某處配置了軟件包源。 VSTS中或Nuget.Config中。 根據日志,您有一個自定義源' http://nuget.ohyeah.net/ ',它不是有效的nuget提要。 如果您有關於配置的更多詳細信息,則將更容易提供幫助。

問題是將舊的TFS xml格式的資源和json格式的VSTS資源混合在一起。 因此,在這個特定問題中,VSTS始終會在json文件中尋找要匹配的id以匹配nuget包,然后VSTS會嘗試檢索nuget包。 如果您有舊的TFS nuget存儲庫,則必須在json文件中創建一個條目。 就我而言,我必須從Nuget.Config中刪除舊的TFS軟件包源,例如http://nuget.XXX.net/api/v2/ 此外,您還需要創建一個有效的@id@type在新的JSON文件字典條目,在我的情況是: https://XXXXXX.pkgs.visualstudio.com/_packaging/Official/nuget/v3/index.json 現在,工作版本如下所示:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
  <disabledPackageSources />
  <packageSources>
      <add key="vsts-official" value="https://XXXXXX.pkgs.visualstudio.com/_packaging/Official/nuget/v3/index.json" />
    <add key="microsoft" value="https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/" />
    <add key="nuget.org" value="" />
  </packageSources>
</configuration>

最簡單的解決方案就是更改 NuGet 包的版本,如下所示。 在 NuGet 還原搜索 V 3.3.0 時,我遇到了同樣的問題。 它在那里,我用它托管代理。 我發現這對我有用。

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM