TeamCity not restoring NuGet packages from particular package source
Asked Answered
P

1

6

I have recently added a bunch of Sitecore NuGet packages to my solution from their new NuGet server: https://sitecore.myget.org/F/sc-packages/api/v3/index.json

But TeamCity doesn't seem to be able to download these:

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

I have amended the list of packages sources in my 'NuGet Installer' build step so that the Sitecore source is the only one, but yet it still can't restore these .dlls. (As a side note: I would have expected other packages to now fail because their source has been removed, but there is no error for those?)

Looking at the logs, I can see the command being fired, which looks correct:

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
Proposition answered 1/11, 2016 at 14:35 Comment(0)
T
8

You've referenced a Nuget v3 feed but it looks like your TeamCity Nuget Installer step is set to use Nuget.exe v2.8.6. Update the setting to use v3+:

Nuget Settings

I would recommend you do not specify the Package sources in TeamCity, and instead use a Nuget.config file next to you .sln file. This also means that each developer does not need to individually add the feed sources in Visual Studio, as well as allowing the feed list to be source controlled. TeamCity will also use this list for the package sources automatically.

<?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>

You can find more details in this blog post about The right way to restore NuGet packages.

Titivate answered 1/11, 2016 at 15:13 Comment(1)
Doh - can't believe I missed that. FYI we do actually have the NuGet.config as part of the solution. I've just been trying a whole load of things to get it workingProposition

© 2022 - 2024 — McMap. All rights reserved.