[英]How to publish .snupkg Source Link package to MyGet using DevOps build pipeline
My build creates Source Link packages, in the form of .snupkg
files, and I'd like to push those packages to MyGet.我的构建以
.snupkg
文件的形式创建源链接包,我想将这些包推送到 MyGet。 From what I understand, tools such as Rider and Visual Studio can then download the symbols automatically.据我了解,Rider 和 Visual Studio 等工具可以自动下载符号。 I can get this
nuget push
command working from my local machine, but I cannot figure out how to push those symbols using a DevOps build task.我可以在我的本地机器上运行这个
nuget push
命令,但我不知道如何使用 DevOps 构建任务推送这些符号。 Here's my YAML:这是我的 YAML:
- task: NuGetCommand@2
displayName: 'Publish Symbols ($(Build_Major).$(Build_Minor).$(Build_Patch))'
condition: succeeded()
inputs:
command: 'push'
packagesToPush: 'projects/${{ parameters.projectName }}/src/**/bin/**/*.$(Build_Major).$(Build_Minor)*.snupkg'
nuGetFeedType: 'external'
publishFeedCredentials: 'MyGet - Test'
I'm absolutely sure that MyGet - Test
is correct, since I'm using the exact URL and API key that the MyGet web UI tells me to use for publishing symbols, as well as the same ones I have working locally.我绝对确定
MyGet - Test
是正确的,因为我使用的是 MyGet web UI 告诉我用于发布符号的确切 URL 和 API 键,以及我在本地工作的相同键。 However, in the build logs I get:但是,在构建日志中我得到:
C:\hostedtoolcache\windows\NuGet\6.4.0\x64\nuget.exe sources Add -NonInteractive -Name redacted_source -Source https://company.myget.org/F/myfeed/api/v3/index.json -ConfigFile D:\a\1\Nuget\tempNuGet_311668.config
Package source with Name: redacted_source added successfully.
Using authentication information for the following URI: https://company.myget.org/F/myfeed/api/v3/index.json
C:\hostedtoolcache\windows\NuGet\6.4.0\x64\nuget.exe setapikey *** -NonInteractive -Source redacted_source -ConfigFile D:\a\1\Nuget\tempNuGet_311668.config
The API Key '***' was saved for 'https://company.myget.org/F/myfeed/api/v3/index.json'.
C:\hostedtoolcache\windows\NuGet\6.4.0\x64\nuget.exe push D:\a\1\s\src\myproject\bin\Release\MyProject.1.10.24-beta.snupkg -NonInteractive -Source https://company.myget.org/F/myfeed/api/v3/index.json -ApiKey *** -ConfigFile D:\a\1\Nuget\tempNuGet_311668.config -Verbosity Detailed
Unable to load the service index for source https://company.myget.org/F/myfeed/api/v3/index.json.
NuGet Version: 6.4.0.123
Response status code does not indicate success: 401 (Unauthorized).
This does work a bit different than how I can successfully do this from the command line, which is:这确实与我从命令行成功执行此操作的方式有点不同,即:
nuget push .\MyProject.1.10.100-mike-beta.nupkg b848309c-0000-0000-0000-a893d8fc5d56 -Source https://company.myget.org/F/myfeed/api/v3/index.json
However, I'm not quite sure how to get the NuGetCommand
task to behave like that.但是,我不太确定如何让
NuGetCommand
任务表现得像那样。 It seems like both should work anyway.看起来两者都应该有效。 Any ideas?
有任何想法吗?
I figured this out, Though.不过,我想通了。 the solution is kinda stupid: You must use a pre-authenticated URL to push packages or symbols using the v3 API:
解决方案有点愚蠢:您必须使用预验证的 URL 来使用 v3 API 推送包或符号:
Authentication seems to work fine using the v2 API, but the v2 API doesn't let you push symbols.身份验证似乎使用 v2 API 可以正常工作,但 v2 API 不允许您推送符号。 I'm not sure if this is a limitation of MyGet or the DevOps NuGet task or what.
我不确定这是 MyGet 或 DevOps NuGet 任务的限制还是什么。 However, since the pre-authenticated URL can still live as a secret in the service connection, it's a fairly easy and secure workaround.
但是,由于预先验证的 URL 仍然可以作为服务连接中的秘密存在,因此这是一个相当简单和安全的解决方法。
I'll leave this question open in case anyone has more insight or a better solution.如果有人有更多见识或更好的解决方案,我会保留这个问题。
You can first create a service connection credential for the feed.您可以先为订阅源创建一个服务连接凭证。
Then add NuGet authenticate task before NuGetCommand@2 task in the pipeline.然后在管道中的NuGetCommand@2任务之前添加NuGet 身份验证任务。
steps:
- task: NuGetAuthenticate@1
displayName: 'NuGet Authenticate'
inputs:
nuGetServiceConnections: feed
Please refer to the document Publish NuGet packages with Azure Pipelines .请参考文档Publish NuGet packages with Azure Pipelines 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.