使用Azure Devops发布Nuget程序包 [英] Publish Nuget Package using Azure Devops

查看:61
本文介绍了使用Azure Devops发布Nuget程序包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Azure DevOps中创建一个发布管道,该发布管道会将程序包发布到Nuget.org.构建管道可以正常工作,并将包创建为构建工件.我可以发布到Azure Artifacts中托管的供稿,而我不能发布到Nuget.org.我相信问题出在服务连接上..

I'm trying to create a Release Pipeline in Azure DevOps that will publish a package to Nuget.org. The build pipeline works just fine and creates the package as the build artifact. I can publish to a feed hosted in Azure Artifacts, I just cannot publish to Nuget.org. I believe the issue is with the Service Connection. .

我尝试使用ApiKey,但是会引发错误

I've tried using the ApiKey but that throws an error

DotNet Core不支持加密的API密钥'错误

DotNet Core does not support encrypted API Key' error

这是试图推包装的释放步骤.

Here is the release step that is attempting to push the package.

我还尝试了 https://api.nuget.org/v3/index.json 作为Feed URL,但这似乎没有什么作用.

I've also tried https://api.nuget.org/v3/index.json for the Feed URL but that doesn't seem to make a difference.

日志输出.

2018-10-21T23:27:36.3177322Z ## [section]开始:Nuget Push2018-10-21T23:27:36.3183449Z =============================================================================2018-10-21T23:27:36.3183547Z任务:.NET Core2018-10-21T23:27:36.3183635Z说明:构建,测试,打包或发布dotnet应用程序,或运行自定义dotnet命令.对于包命令,支持NuGet.org以及经过身份验证的提要,例如包管理"和"MyGet".2018-10-21T23:27:36.3183729Z版本:2.141.02018-10-21T23:27:36.3183791Z作者:Microsoft Corporation2018-10-21T23:27:36.3183871Z帮助:更多信息2018-10-21T23:27:36.3183936Z =============================================================================2018-10-21T23:27:37.1663123Z [command] C:\ Windows \ system32 \ chcp.com 650012018-10-21T23:27:37.1762529Z活动代码页:650012018-10-21T23:27:37.1808736Z SYSTEMVSSCONNECTION存在true2018-10-21T23:27:37.3473599Z SYSTEMVSSCONNECTION存在true2018-10-21T23:27:37.4707171Z SYSTEMVSSCONNECTION存在true2018-10-21T23:27:37.4739974Z e3e8a3af-5c6c-44e9-820c-c62af0972256存在true2018-10-21T23:27:37.4807474Z将NuGet.config保存到一个临时配置文件中.2018-10-21T23:27:37.4833034Z将NuGet.config保存到一个临时配置文件中.2018-10-21T23:27:37.4919745Z对以下URI使用身份验证信息: https://www.nuget.org/api/v2/package 2018-10-21T23:27:37.4988034Z [command] C:\ hostedtoolcache \ windows \ dncs \ 2.1.105 \ x64 \ dotnet.exe nuget push"{package}" --source https://www.nuget.org/api/v2/package '...2018-10-21T23:27:38.4171650Z信息:PUT https://www.nuget.org/api/v2/package/2018-10-21T23:27:38.8798808Z信息:禁止 https://www.nuget.org/api/v2/package/ 462毫秒2018-10-21T23:27:38.9562536Z错误:响应状态代码未指示成功:403(指定的API密钥无效,已过期或没有访问指定软件包的权限.)2018-10-21T23:27:40.2195255Z ## [错误]错误:C:\ hostedtoolcache \ windows \ dncs \ 2.1.105 \ x64 \ dotnet.exe失败,返回码:12018-10-21T23:27:40.2206711Z ## [错误]包无法发布2018-10-21T23:27:40.2307763Z ## [section]完成:Nuget Push

2018-10-21T23:27:36.3177322Z ##[section]Starting: Nuget Push 2018-10-21T23:27:36.3183449Z ============================================================================== 2018-10-21T23:27:36.3183547Z Task : .NET Core 2018-10-21T23:27:36.3183635Z Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet. 2018-10-21T23:27:36.3183729Z Version : 2.141.0 2018-10-21T23:27:36.3183791Z Author : Microsoft Corporation 2018-10-21T23:27:36.3183871Z Help : More Information 2018-10-21T23:27:36.3183936Z ============================================================================== 2018-10-21T23:27:37.1663123Z [command]C:\Windows\system32\chcp.com 65001 2018-10-21T23:27:37.1762529Z Active code page: 65001 2018-10-21T23:27:37.1808736Z SYSTEMVSSCONNECTION exists true 2018-10-21T23:27:37.3473599Z SYSTEMVSSCONNECTION exists true 2018-10-21T23:27:37.4707171Z SYSTEMVSSCONNECTION exists true 2018-10-21T23:27:37.4739974Z e3e8a3af-5c6c-44e9-820c-c62af0972256 exists true 2018-10-21T23:27:37.4807474Z Saving NuGet.config to a temporary config file. 2018-10-21T23:27:37.4833034Z Saving NuGet.config to a temporary config file. 2018-10-21T23:27:37.4919745Z Using authentication information for the following URI: https://www.nuget.org/api/v2/package 2018-10-21T23:27:37.4988034Z [command]C:\hostedtoolcache\windows\dncs\2.1.105\x64\dotnet.exe nuget push "{package}" --source https://www.nuget.org/api/v2/package --api-key RequiredApiKey 2018-10-21T23:27:38.3984300Z info : Pushing TranslatorConsole.1.0.0.6.nupkg to 'https://www.nuget.org/api/v2/package'... 2018-10-21T23:27:38.4171650Z info : PUT https://www.nuget.org/api/v2/package/ 2018-10-21T23:27:38.8798808Z info : Forbidden https://www.nuget.org/api/v2/package/ 462ms 2018-10-21T23:27:38.9562536Z error: Response status code does not indicate success: 403 (The specified API key is invalid, has expired, or does not have permission to access the specified package.). 2018-10-21T23:27:40.2195255Z ##[error]Error: C:\hostedtoolcache\windows\dncs\2.1.105\x64\dotnet.exe failed with return code: 1 2018-10-21T23:27:40.2206711Z ##[error]Packages failed to publish 2018-10-21T23:27:40.2307763Z ##[section]Finishing: Nuget Push

推荐答案

在Github中跟踪了一个问题: DotNetCore当前不支持使用加密的Api密钥

There is an issue tracked in Github: DotNetCore currently does not support using an encrypted Api Key

dotnet当前不支持使用ApiKey,因为加密密钥所需的库不可用,对不起不便.您应该能够使用服务端点配置了用户名/密码组合.如果只能使用一个ApiKey,我建议使用nuget 2. *任务进行推送.

Using an ApiKey is currently not supported in dotnet because the required libraries for encrypting the key are not available, sorry for the inconvenience. You should be able to use a service endpoint configured with a username/password combination. If you can only use an ApiKey, I would suggest using the nuget 2.* task to push.

因此,您可以尝试使用 Nuget 2.* 任务来推送软件包.(添加任务->程序包-> Nuget)

So, you can try using the Nuget 2.* task to push the packages. (Add task --> Package --> Nuget)

或者,您可以尝试通过调用 dotnet nuget push 命令来通过命令行任务将软件包推送到NuGet服务器.引用此线程:尝试从VSTS推送nuget软件包时出错

Alternately you can try pushing package to NuGet server through Command Line task by calling dotnet nuget push command to deal with this issue. Reference this thread: error while trying to push nuget package from VSTS

这篇关于使用Azure Devops发布Nuget程序包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆