我在使用从 gitlab 下载的特定 nuget 包时遇到问题。从源检索信息时,我们要么收到错误“NU1301:无法加载源的服务索引”,要么收到 401 错误。
nuget source Add -Name "GitLab" -Source "https://Organization.git.com/packages/nuget/index.json" -UserName git.Organization.com\Username -Password PersonalAccessToken
当我们查看命令“nugetsources”时,该值显示为已启用。
1. https://www.nuget.org/api/v2/ [Enabled]
https://www.nuget.org/api/v2/
2. GitLab [Enabled]
https://Organization.git/packages/nuget/index.json
但是,当我们使用以下命令“dotnet nuget list source --formatDetailed”查看nuget列表源时,我们不仅看不到Gitlab源,而且看到了不同版本的nuget。
Registered Sources:
1. nuget.org [Enabled]
https://api.nuget.org/v3/index.json
关于故障排除,我们添加了一个包含凭据的 nuget.config 文件
<configuration>
<packageSources>
<clear /> <!-- clear to make sure that everyone uses the same sources -->
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="GitLab" value="https://Organization.git.com/packages/nuget/index.json" />
</packageSources>
<packageSourceCredentials>
<GitLab>
<add key="UserName" value="Username" />
<add key="Password" value="Token" />
</GitLab>
</packageSourceCredentials>
</configuration>
我们如何确保来自 gitlab 的 nuget 包已启用和/或如何将凭据传递给 gitlab?谢谢!
我们还查看了各种用户名,例如 git.organization.com\username、“username”和 https://git.organization.com\username。
你能解决这个问题吗?