我在2015年TFS Build期间遇到了NuGet包恢复问题。
由于某些软件包需要NuGet 3.x客户端,我已经将新的脚本化构建配置为使用自定义NuGet位置,其中我放置了 NuGet Command-Line 3.x beta 的可执行文件
每当我运行构建时,所有软件包都无法恢复,NuGet会抛出“无法找到版本......”错误:
Unable to find version '1.1.10' of package 'Microsoft.Bcl'.
Unable to find version '4.0.10' of package 'System.Threading'.
Unable to find version '1.1.37' of package 'System.Collections.Immutable'.
Unable to find version '1.0.0' of package 'Owin'.
Unable to find version '4.1.0' of package 'NLog'.
Unable to find version '7.0.1' of package 'Newtonsoft.Json'.
Unable to find version '2.0.1' of package 'MongoDB.Driver.Core'.
Unable to find version '2.0.1' of package 'MongoDB.Driver'.
Unable to find version '2.0.1' of package 'MongoDB.Bson'.
Unable to find version '3.0.1' of package 'Microsoft.Owin.Security.OAuth'.
......还有更多的包裹。我相信这个问题很清楚。
当我使用Visual Studio在构建计算机中构建相同的解决方案时,所有包都可以成功恢复。
我该如何解决这个问题?
答案 0 :(得分:22)
就我而言,问题是位于NuGet.config
的用户范围C:\Users\[User name]\AppData\Roaming\NuGet\NuGet.config
(其中[User name]
是运行构建代理的Windows的用户service)指向NuGet API v2 while my build is already using NuGet Command-Line 3.x。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<!-- CHANGING V2 TO V3 IN THE URI VALUE SOLVED THE ISSUE! -->
<add key="nuget.org" value="https://www.nuget.org/api/v3/" />
</packageSources>
</configuration>
答案 1 :(得分:3)
在我的情况下,Nuget.Config
位于:
C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\NuGet
因此,请在Nuget.Config
中搜索C:\
。
用户取决于您配置Agent
答案 2 :(得分:1)
如果由于某种原因更新Roaming文件夹中的NuGet.config
不是一个选项或不需要的,也可以将配置文件添加到解决方案根目录。
根据文件:
答案 3 :(得分:0)