How to get TFS2015 Build (Build.vnext) and NuGet package restore to use custom package sources
Solution 1:
Alternatively you could also add a NuGet Installer
build step before the Visual Studio Build
step in your build configuration to restore all NuGet packages.
There you can pass the location of your private repo as argument to nuget.exe
:
-source "https://www.nuget.org/api/v2/;http://mynugetserver"
Solution 2:
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.
Solution 3:
Add a NuGet.config to your project that specifies an alternate package location. The rules for resolution are well-defined and explained in the official documentation.
Solution 4:
There is a new VSTS Task called "NuGet Installer" this allows you to check in your NuGet.config file and specify the different package sources. Run this task before you run MSBuild.
If you are using the VSTS NuGet Feed you will need to add the build service account to the feed to enable downloading of packages https://www.visualstudio.com/get-started/package/use/common-identities