packages.config to include source of package

Topics: General
Nov 25, 2014 at 3:02 PM
Edited Nov 25, 2014 at 3:05 PM
Currently the packages.config does not have the source of package. In most cases, the package will be available from the public site www.nuget.org

So the current packages.config looks like
<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Newtonsoft.Json" version="6.0.6" targetFramework="net453" />
</packages>
When enterprises have an internal Nuget repository of certified libraries / components, there should be some way to mention the package source url in the packages.config. This will allow build automation process to retrieve Nuget packages from internal repositories instead of external Nuget repository.

So the above packages.config could look something like,
<?xml version="1.0" encoding="utf-8"?>
<nuget>
  <sources>
    <source id="local" url="C:\Punit Ganshani\Repository\Nuget" />
    <source id="internal" url="http://nuget.myorg-intranetsite.com/api/v1" />
    <source id="external" url="https://www.nuget.org/api/v2" />
  </sources>
  <packages>
    <package id="Newtonsoft.Json" version="6.0.6" targetFramework="net453" />
  </packages>
</nuget>
So as per the precedence of sources mentioned in the packages.config file, the build process could look for assemblies and have fallback sources as well.

Of course, the format of packages.config can be different per compatibility with other ecosystems; or this package source information could also be captured in a different configuration file as well. But this feature will be really helpful where build processes/servers have restricted access to Internet