skipnothing/.NET Platform

Sources, Feeds & Mapping

You list two servers in a config file, run `dotnet restore`, and whichever answers first hands over the package. Swap their order in the file and the result can change on its own, because the order was never a ranking.

  • Reorder your feeds all you like: restore ignores the order and takes whichever server answers the request first.
  • A repo nuget.config that adds one private server is still quietly racing nuget.org, until one line removes it.
  • The same package name on two servers is an open door; source mapping locks which one may answer.
BUILDS ON
01

Restore races every source at once

A nuget.config can list several servers to pull packages from:

<packageSources>
  <add key="contoso" value="https://pkgs.contoso.example/v3/index.json" />
  <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>

Each <add> is a package source. Run dotnet restore and it is tempting to read that list top-down: first server wins, second is a fallback. It does not work that way. Restore asks every enabled source for the package at once and takes the answer from whichever one responds first. The order you wrote them in is ignored.

When a package id lives on exactly one source, the race has one entrant and the outcome is obvious. When the same id lives on two, the winner is whichever replies fastest on that run, which can differ machine to machine. The list was never a ranking. It is a set of package sources restore queries in parallel.

TWO SOURCES, ONE RACE

Keep going, sign up to unlock the rest

3 more parts in this topic, plus 25+ more topics in .NET Platform.

Sign up, it's freeSee the full .NET Platform
Build & Distribution0/4#25 Asset Flow & References