“无法找到版本"在TFS Build 2015中还原NuGet软件包时 [英] "Unable to find version" during TFS Build 2015 when restoring NuGet packages

查看:146
本文介绍了“无法找到版本"在TFS Build 2015中还原NuGet软件包时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在TFS Build 2015期间,我在NuGet软件包还原方面遇到了麻烦.

I'm having troubles with NuGet package restoring during a TFS Build 2015.

由于某些软件包需要NuGet 3.x客户端,因此我将新的可脚本化版本配置为使用自定义的NuGet位置,在该位置中放置了 NuGet命令行3.x beta版的可执行文件

Since some packages require NuGet 3.x client, I've configured the new scriptable build to use a custom NuGet location where I've placed the executable of NuGet Command-Line 3.x beta.

每当我运行一个版本时,所有软件包都将无法还原,NuGet会抛出无法找到版本..." 错误:

Whenever I run a build, all packages can't be restored and NuGet throws the "Unable to find version..." error:

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'.

...以及更多软件包.我相信问题很明显.

...and even more packages. I believe the issue is clear.

当我使用Visual Studio在构建计算机中构建相同的解决方案时,所有软件包都将成功还原.

When I build the same solution in the build machine using Visual Studio, all packages are restored sucessfully.

我该如何解决?

推荐答案

在我来说,问题是用户级NuGet.config位于C:\Users\[User name]\AppData\Roaming\NuGet\NuGet.config(其中[User name]是运行构建代理程序Windows的用户)服务)指向NuGet API v2

In my case, the issue was that user-wide NuGet.config located at C:\Users\[User name]\AppData\Roaming\NuGet\NuGet.config (where [User name] is the user who's running the build agent's Windows service) was pointing to 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> 

这篇关于“无法找到版本"在TFS Build 2015中还原NuGet软件包时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆