无法使用dotnet core添加nuget包

时间:2019-02-19 11:39:11

标签: .net-core nuget-package

我正在尝试使用dotnet核心CLI通过以下命令安装xunit NuGet软件包:

dotnet add package xunit -s https://api.nuget.org/v3/index.json

从类库文件夹中。但是,我在执行该行时看到了这一点:

  Writing C:\Users\<myuser>\AppData\Local\Temp\tmp7238.tmp
info : Adding PackageReference for package 'xunit' into project 'C:\git\Testing\TestLib\TestLib.csproj'.
log  : Restoring packages for C:\git\Testing\TestLib\TestLib.csproj...
info :   CACHE https://api.nuget.org/v3-flatcontainer/xunit/index.json
error: Unable to load the service index for source https://<mysourcecontrol>.pkgs.visualstudio.com/_packaging/libs/nuget/v3/index.json.
error:   Response status code does not indicate success: 401 (Unauthorized).

AFAIK,这告诉我机器上的nuget实用程序找不到有关本地NuGet源的相关信息。我不明白的是为什么这甚至是一个问题-我指定要使用的源(这是常规的nuget.org路径)。

1 个答案:

答案 0 :(得分:0)

结果显示%appdata%\nuget\nuget.config包含NuGet工具不喜欢的条目。我删除了它们,然后重试,安装成功了。