如何解决dotnet add package with source 给出未授权错误 401 和 404 Not found
我们正在更新 dotnet 应用程序中的 nuget 包,并使用来自 Azure Devops 中的私有源的 dotnet add 包“包名称”。 最近我们更新到 .net 5.0.1(我不确定它是否与问题有关。) 但是现在在运行上述命令时,在本地机器以及 azure piplelines 中都会出现错误。 我已经尝试了 --interactive 选项并刷新了包等的 PAT。
command dotnet add "csprojFile" package "mypackageName"
Determining projects to restore...
Writing C:\Users\SirajUrRahman\AppData\Local\Temp\tmpD8BD.tmp
info : Adding PackageReference for package 'my package' into project '.\my csproj'.
info : GET https://api.nuget.org/v3/registration5-gz-semver2/mypackageName/index.json
info : NotFound https://api.nuget.org/v3/registration5-gz-semver2/mypackageName/index.json 889ms
error: Unable to load the service index for source https://pkgs.dev.azure.com/myorganization/_packaging/Feed/nuget/v3/index.json.
error: Response status code does not indicate success: 401 (Unauthorized).
Usage: NuGet.CommandLine.XPlat.dll package add [options]
Options:
-h|--help Show help information
--force-english-output Forces the application to run using an invariant,English-based culture.
--package Id of the package to be added.
--version Version of the package to be added.
-d|--dg-file Path to the dependency graph file to be used to restore preview and compatibility check.
-p|--project Path to the project file.
-f|--framework Frameworks for which the package reference should be added.
-n|--no-restore Do not perform restore preview and compatibility check. The added package reference will be unconditional.
-s|--source Specifies NuGet package sources to use during the restore.
--package-directory Directory to restore packages in.
--interactive Allow the command to block and require manual action for operations like authentication.
--prerelease Allows prerelease packages to be installed.
感谢您的帮助。 如果需要,请随时提出任何问题。
解决方法
此问题与 .net 5 相关,并且在 github 上已经为此创建了一个错误,这是该问题的链接。 https://github.com/NuGet/Home/issues/10305。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。