4
votes

I have setup a new team project on VSTS for our development team and am using the Package-Management extension for publishing our NuGet packages. I have also enabled the public nuget.org feed as an upstream source for our internal package feed.

As recommended here & here I have unchecked nuget.org as a package source within Visual Studio.
Now I expect the search to find packages published to this feed first and if not then fetch it from the upstream. But this is not the case and am unable to add packages from nuget.org unless I enable nuget.org as a package source from within Visual Studio.

Packages from nuget.org (that where added by enabling nuget.org) start appearing in my private feed once I publish packages to my feed.(even after I uncheck nuget.org source) But I can't consume new packages directly from the upstream without enabling nuget.org as a source.

Have I misunderstood this is this supposed to be a build machine configuration rather than a developer machine configuration?

3
Did you find a solution to this? I don't want nuget.org to spam our internal feed. But when I don't enable "Use packages from NuGet.org", obviously the builds fail.Heinzlmaen
haven't used recently, but guessing from your comment, the behaviour hasn't changed muchVignesh.N

3 Answers

3
votes

You missed this section in the documentation:

If you're using upstream sources, package-versions in the upstream source that haven't yet been saved into your feed (by using them at least once) won't appear in the NuGet Package Manager search. To install these packages:

  1. On the upstream source (e.g. nuget.org), copy the Install-Package command.
  2. In Visual Studio, open the Package Manager Console from Tools -> NuGet Package Manager.
  3. Paste the Install-Package command into the Package Manager Console and run it.
0
votes

In Visual Studio (I'm using VS 2019), updated versions of packages from upstream should appear in the dropdowns automatically, except in the following case:

If PackageA depends on PacakageB, but PackageB is not explicitly installed (i.e. you didn't add it explicitly in your project's Manage NuGet Packages page), then PackageB will be frozen at the last version that was implicitly installed.

Example:

  1. On your Manage NuGet Packages page you install System.Text.Json version 5.0.0. This causes your app to be implicitly dependent on System.Text.Encodings.Web 5.0.0.

  2. Some time later, you upgrade System.Text.Json to version 5.0.1. There is also a new version 5.0.1 of System.Text.Encodings.Web, but since System.Text.Json 5.0.1 depends on System.Text.Encodings.Web >= 5.0.0, the version already in your feed satisfies the implicit dependency. Your feed will keep version 5.0.0.

  3. Sometime later you need to update to System.Text.Encodings.Web version 5.0.1. You search for System.Text.Encodings.Web on the NuGet package page, but notice that version 5.0.0 is the only version available!

  4. Solution

    4.1. Click Install on version 5.0.0. This will make the package an explicit dependency.

    4.2. Now, on the updates tab, you will see 5.0.1 appear as an update option.

-2
votes

As you found, you do should also select nuget.org package source (both select you VSTS feed and nuget.org as package sources).

enter image description here

If you un-select nuget.org package source in VS, that means packages from nuget.org won’t be available.

For the purpose to search a package from VSTS feed first, and then search in nuget.org, you can achieve it by filtering packages from different package sources:

  • To search a package (such as NUnit package) from VSTS feed (the name is new for below example) first:

    Sepecifying Package source as new, if there shows the related package(s) in browse list, then you can use the package(s) from VSTS feed. If there has no packages list, that means VSTS feed does not have related packages, then you can serarch from nuget.org as below step.

    enter image description here

  • To serach the package (NUnit) from nuget.org, you just need to change the package source as nuget.org, then VS will list related packages which store in https://api.nuget.org/v3/index.json.

    enter image description here