【发布时间】:2015-05-28 16:28:00
【问题描述】:
我正在尝试从 Nuget 存储库下载包,该存储库需要使用 NuGet.Core 访问它的凭据。
我知道没有身份验证的 Nuget 存储库可以按如下方式访问:
//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"));
(来源:Nuget blog)
现在假设我拥有 Nuget 存储库的凭据。 我尝试使用 http 客户端和网络凭据获取包,但它不起作用。 那么如何将凭据传递给 Nuget 服务器?
我也想知道如何restrict access to a Nuget feed(新版本提供什么?)。
我似乎找不到任何明确的文档。
谢谢。
【问题讨论】:
标签: api authentication nuget nuget-server