Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 959
Jaans Avatar asked Jul 13 '15 13:07

Jaans


People also ask

How do I force a NuGet package to restore?

Restore packages manually or automatically After you enable package restore in Options, you can right-click the solution in Solution Explorer and select Restore NuGet Packages to restore packages anytime.

Does MSBuild restore NuGet packages?

msbuild -t:Restore will restore nuget packages for projects with PackageReference nuget management format. And your situation looks like packages. config nuget management format which you have used it.

How do I add package sources in Visual Studio?

In Visual Studio, select Tools, and then select Options. Select NuGet Package Manager, and then select Package Sources. Enter the feed's Name and Source URL, and then select the green (+) sign to add a new package source.

How do I add a source to a NuGet package?

To manage your package sources, select the Settings icon or select Tools > Options. In the Options window, expand the NuGet Package Manager node and select Package Sources. To add a source, select +, edit the Name, enter the URL or path in Source, and then select Update.


1 Answers

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"

like image 111
Pascal Berger Avatar answered Oct 08 '22 02:10

Pascal Berger