Search code examples
tfstfsbuildazure-devopstfs-2015nuget-package-restore

How to get TFS2015 Build (Build.vnext) and NuGet package restore to use custom package sources


I'm trying to get our TFS2015 Build (TFSBuild vnext) going along with VS Team Services.

Thus far most blogs and documentation has been helpful, except for when trying to build a project that uses custom package sources for NuGet automatic package restore.

I've successfully deployed an a Team Services Build Agent (the new mechanism for builds) and all seemed to go well until the build task to Restore NuGet packages failed.

The failure was due to custom/private package source not being picked up from the installed VS configuration, so those packages could not be found. The traditional packages from the default NuGet package feed did restore without issue.

How do I specify the additional package sources for NuGet to use when using an agent?

EDIT: vcastro asked about the NuGet Installer build step and defining paths in the configuration of that build step. The above is using the Visual Studio Build step and the integrated option to have NuGet restore packages. Refer this image for reference: http://i.imgur.com/Hrqhhk2.png


Solution

  • I've scrounged the web with little success, but after fiddling the following will help:

    OK It seems that the package sources configured for NuGet.config is stored per user account, e.g.

    c:\Users\<<username>>\AppData\Roaming\NuGet\NuGet.config

    My issue was harder to resolve, because the build agent was running as a Windows Service under the Local System account. So to get NuGet configuration to for the build, I had to use the following path instead:

    • 64-bit Windows C:\Windows\SysWOW64\config\systemprofile\AppData\Roaming\NuGet\NuGet.Config
    • 32-bit Windows C:\Windows\System32\config\systemprofile\AppData\Roaming\NuGet\NuGet.Config

    You may need to have elevated permissions in order to create the NuGet subfolder and NuGet.Config file.

    Note: I have no solution for using the Local Service account. The above only works for the Local System (or an actual user) account.