tfsnugettfsbuildnuget-package-restorebuild-agent

Unable to find NuGet package version in TFS build?


I am using TFS 2017 and NuGet Installer - 0 task for NuGet restore in build definition but getting an error unable to find version.

It's using below command for restoring packages

D:\agent\_work\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.31\node_modules\nuget-task-common\NuGet\3.3.0\NuGet.exe restore -NonInteractive D:\agent\_work\42\s\xyz\xyz.sln -Verbosity Detailed

Unable to find version '3.2.7' of package 'Microsoft.AspNet.WebPages'.
2020-06-15T14:50:36.6499535Z Unable to find version '5.2.7' of package 'Microsoft.AspNet.WebApi.WebHost'.
2020-06-15T14:50:36.6499535Z Unable to find version '5.2.7' of package 'Microsoft.AspNet.WebApi.Core'.
2020-06-15T14:50:36.6499535Z Unable to find version '5.2.7' of package 'Microsoft.AspNet.WebApi.Client'.
2020-06-15T14:50:36.6499535Z Unable to find version '5.2.7' of package 'Microsoft.AspNet.Mvc'.

But when I run same above command manually on the agent it's working fine also tried updating NuGet task version.


Solution

  • Unable to find version '3.2.7' of package xxx

    Agree with Etienne. The versions of these packages can be found in nuget.org.

    When you use the Nuget Restore task in TFS2017, you could try the following methods to use the nuget.org.

    1. Use the Nuget Restore task V1. Select the Use Packages from nuget.org option.

    enter image description here

    1. If you use the nuget.config file , you could add the nuget.config package source in the file.

      <?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <clear /> <add key="nuget.org" value="https://api.nuget.org/v3/index.json"protocolVersion="3" /> </packageSources> </configuration>

    Here is a doc about nuget.config file.

    Hope this helps.