![](/img/trans.png)
[英]Wrong version number in packages folder when using “nuget.exe restore solution”
[英]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>
順便說一句,您提供的代碼不是用於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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.