Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding internal NuGet server to TFS build server?

We have a private NuGet server and my issue is the TFS 2017 builds don't recognize the internal package's NuGet server, obviously, without specifying the URL. I've tried putting it in Nuget.config and it worked, but with some issues.

What I would like to do, however, is somehow add this to the global list of feeds. I do not have NuGet installed on the server, though NuGet restore is happening as a build Task, so it exists under c:_work_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.21\ etc, and do not see anything that would let me change the set of feeds.

BTW, when I added a package source to nuget.config, it seemed to ONLY download from that source and ignored all the defaults, such as nuget.org, etc.

How can I add an internal nuget server so that all my builds natively can access it? Thanks.

like image 759
Ryan Peters Avatar asked Dec 14 '17 18:12

Ryan Peters


1 Answers

Generally you just need to add the feeds (also add the nuget.org source) to NuGet.config file, then check in the file.

(If you used the third private NuGet server, then you can have a try with the Package Management in VSTS and TFS)

e.g.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <!-- remove any machine-wide sources with <clear/> -->
    <clear />
    <!-- add a VSTS feed -->
    <add key="MyGreatFeed" value="https://fabrikam.pkgs.visualstudio.com/DefaultCollection/_packaging/MyGreatFeed/nuget/v3/index.json" />
    <!-- also get packages from the NuGet Gallery -->
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
  </packageSources>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
</configuration>

For this issue : "it seemed to ONLY download from that source and ignored all the defaults, such as nuget.org, etc."

Make sure you have correctly set the NuGet.config file and the nuget.org source is not excluded.

To Restore NuGet packages in Build you can follow the steps mentioned in below article:

Restore Package Management NuGet packages in Team Build

  • If you've checked in a NuGet.config, select Feeds in my NuGet.config and select the file from your repo.
  • If you're using a single VSTS/TFS feed, select the Feed(s) I select here option and select your feed from the dropdown.
like image 181
Andy Li-MSFT Avatar answered Sep 19 '22 16:09

Andy Li-MSFT