My company hosts our own internal NuGet package repository for us to upload our own private, proprietary packages to. We still use the official NuGet.org repository for pulling down all the public packages. We also enable Package Restore in our projects to allow our build to download missing packages.
We have added our own NuGet repo to the list in Tools > Library Package Manager > Package Manager Settings > Package Sources
and we have also left the default one (NuGet official package source) in the list as well. We also have our own repo in the NuGet.targets
file as a PackageSource
element. The offical repo is not included as a PackageSource
in that file though.
This has worked for us for several months. When we release new version of our own packages to our repo, they are visible to the projects. Also, when new public packages become available, our projects haven't had any problems finding them on nuget.org.
Just recently however, the build has started failing to download packages from the official repo. When I build the solution, the output contains the following line for every project which references missing packages we aren't hosting on our own repo:
C:\code\MyCodebase\.nuget\nuget.targets(79,9): error MSB3073: The command ""C:\code\MyCodebase\.nuget\nuget.exe" install "C:\code\MyCodebase\MyProject\packages.config" -source "http://nuget.example.com/repo/" -o "C:\code\MyCodebase\packages"" exited with code -1.
If I run that command from the command line myself, I see this output in bright red:
Unable to find version '2.5.10.11092' of package 'NUnit'.
Unable to find version '1.2.0' of package 'Common.Logging'.
I assume this is happening because our repo doesn't contain any NUnit packages and the -Source
parameter isn't using the official repo.
My question is: Why did it used to work? Am I crazy? Or has something in the NuGet.exe
behavior changed in a recent update? I was under the impression that NuGet always used the official repo as a final fallback and it seemed that way up until yesterday.
Is the only solution to add the official NuGet repo into the NuGet.targets
file? What is the best way to handle having private and public package dependencies in the same solution? I would like to avoid having to upload all the public packages we use to our own repo.