无权在私有存储库URL上运行FindPackagesById-Nuget

时间:2019-01-07 18:00:05

标签: c# nuget

我正在运行以下代码:

// ---- Download and install a package at a desired path ----
string packageID = "<id>";
var sourceUri = "<privateurl>";
string version = "<version>";
string packagesPath = "<>";
string packagesConfigPath = "<>/packages.config";

//Connect to the official package repository
IPackageRepository sourceRepository = PackageRepositoryFactory.Default.CreateRepository(sourceUri);

IPackage package = sourceRepository
    .FindPackagesById(packageID)
    .SingleOrDefault(p => p.Version.ToFullString()
    .Equals(version));

并引发此错误:

System.InvalidOperationException: An error occurred while loading packages from '<privateurl>/nuget/v3/index.json': The remote server returned an error: (401) Unauthorized. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.

我在做什么错了?

在我的nuget软件包管理器设置中,我在其中看到url,在我的nuget.config中,我也在其中看到它,并且我有权使用它。

0 个答案:

没有答案