I am trying to download packages from a Nuget repository which requires credentials for it to be accessed using NuGet.Core.
I know that Nuget repositories with no authentication can be accessed as follows:
//ID of the package to be looked up
string packageID = "EntityFramework";
//Connect to the official package repository
IPackageRepository repo = PackageRepositoryFactory.Default.CreateRepository("https://packages.nuget.org/api/v2");
//Initialize the package manager
string path = <PATH_TO_WHERE_THE_PACKAGES_SHOULD_BE_INSTALLED>
PackageManager packageManager = new PackageManager(repo, path);
//Download and unzip the package
packageManager.InstallPackage(packageID, SemanticVersion.Parse("5.0.0"));
(source: Nuget blog)
Now suppose I have the credentials of a Nuget repository. I tried to get the package using http client and network credentials but it did not work. So how do I pass the credentials along to the Nuget server?
Also I would like to know how to restrict access to a Nuget feed(what do newer versions offer?).
I can't seem to find any clear documentation.
Thanks.