2015-09-07 55 views
16

我有麻烦与NuGet包一个TFS期间恢复到2015年建设“无法找到版本” TFS中构建2015年恢复的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

你有没有安装任何Microsoft.CodeAnalysis的NuGet软件包?我做了,我开始得到这些错误,当我删除所有这些,然后再次开始工作。 – Schenz

+0

@Schenz我没有这个NuGet包 –

回答

21

在我的情况下,问题是,用户范围位于C:\Users\[User name]\AppData\Roaming\NuGet\NuGet.config(其中[User name]是谁的运行生成代理的Windows服务的用户)NuGet.config指着的NuGet API第2 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> 
+0

我有一个类似的问题,但只有当试图通过包管理器控制台安装包时;包管理器对话框工作正常。这个答案指出了我的正确方向:它是包源代码的URL。在我的情况下,Nuget.config中的URL说''https://www.nuget.org/api/v2/“'。当我删除“www”,将其改为“”https://nuget.org/api/v2/“'它工作。 –

+5

https://www.nuget.org/api/v3/ - 这个位置不存在(https://api.nuget.org/v3/index.json确实)...并且这里定义了两个键都有相同的ID(“nuget.org”) – CJBS

+0

在我的情况下,第三个版本已经准备好在配置中。我刚刚删除了配置文件的所有内容,它帮助: <?xml version =“1.0”encoding =“utf-8”?> David

3

在我的情况Nuget.Config,是:

C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\NuGet 

C:\所以搜索Nuget.Config

用户取决于您配置的Agent

-1

确保包源检查帐户...

进入工具 - > NuGet包管理器 - >软件包管理器设置

然后点击“包装来源”,并确保包装被选中。

enter image description here

+1

但我们正在讨论TFS Build –

+0

所有的包都签入TFS? – Zenacity

+0

是啊!!!!!!!!!!!! –

1

如果由于某种原因在漫游文件夹更新NuGet.config是不是一种选择或不想要的,也可以将配置文件添加到解决方案根。

根据该文档:

  • 项目特定的位于任何文件夹中从溶液中夹到驱动器根NuGet.Config文件。这些允许对设置进行控制,因为它们适用于项目或一组项目。
  • 位于解决方案的.nuget文件夹中的特定于解决方案的NuGet.Config文件。此文件中的设置仅适用于解决方案范围的软件包,并且仅在NuGet 3.3及更早版本中受支持。 NuGet 3.4及更高版本将忽略它。

Config file locations and uses

+0

不错的加法。看来这个问题有很多解决方法/解决方案取决于具体情况! –

相关问题