"Unable to find version" during TFS Build 2015 when restoring NuGet packages

If for some reason updating the NuGet.config in the Roaming folder is not an option or unwanted, it is also possible to add the config file to the solution root.

According to the docs:

  • Project-specific NuGet.Config files located in any folder from the solution folder up to the drive root. These allow control over settings as they apply to a project or a group of projects.
  • A solution-specific NuGet.Config file located within a .nuget folder in the solution. Settings in this file apply only to solution-wide packages and is supported only in NuGet 3.3 and earlier. It is ignored for NuGet 3.4 and later.

Config file locations and uses


In my case the Nuget.Config, was in:

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

So search for Nuget.Config in your C:\.

The user depends on the account that you configured the Agent


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>