TeamCity无法从特定的软件包源还原NuGet软件包

6

最近我从Sitecore的新NuGet服务器(https://sitecore.myget.org/F/sc-packages/api/v3/index.json)添加了一堆Sitecore NuGet包到我的解决方案中。

但是TeamCity似乎无法下载这些包:

[12:45:16][restore] Unable to find version '8.1.160302' of package 'Sitecore.ContentSearch.Linq.NoReferences'.
[12:45:16][restore] Unable to find version '8.1.160302' of package 'Sitecore.ContentSearch.NoReferences'.
[12:45:16][restore] Unable to find version '8.1.160302' of package 'Sitecore.Kernel'.
[12:45:16][restore] Unable to find version '8.1.160302' of package 'Sitecore.Kernel.NoReferences'.

我已经修改了“NuGet Installer”构建步骤中的软件包源列表,使Sitecore成为唯一的软件包源,但仍然无法恢复这些.dll文件。(顺便说一句:我本来以为其他软件包现在会因为它们的源已被删除而失败,但是没有出现错误?) 查看日志,我可以看到被触发的命令看起来是正确的:
C:\TeamCity\buildAgent\tools\NuGet.CommandLine.2.8.6\tools\NuGet.exe restore C:\TeamCity\buildAgent\work\52ce411043f6b04c\MySolution.sln -Source https://sitecore.myget.org/F/sc-packages/api/v3/index.json
1个回答

8
您引用了一个Nuget v3源,但是您的TeamCity Nuget Installer步骤设置为使用Nuget.exe v2.8.6。请更新设置以使用v3+版本:Nuget Settings 我建议您不要在TeamCity中指定软件包源,而是在.sln文件旁边使用Nuget.config文件。这也意味着每个开发人员不需要在Visual Studio中单独添加源,同时允许将源列表纳入源代码控制。TeamCity也会自动使用此列表作为软件包源。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="Sitecore NuGet Feed" value="https://sitecore.myget.org/F/sc-packages/api/v3/index.json" />
    <add key="Custom Server" value="http://my-custom-server.org/api/v3/" />
  </packageSources>
</configuration>

您可以在这篇关于恢复NuGet程序包的正确方法的博客文章中找到更多细节。


2
糟糕 - 真不敢相信我错过了那个。顺便说一下,我们实际上已经将 NuGet.config 作为解决方案的一部分。我一直在尝试各种方法来让它工作。 - David Masters

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接