VSO NuGet Publisher构建步骤失败

时间:2015-11-18 09:51:37

标签: azure-devops azure-pipelines azure-artifacts

我正在使用Visual Studio Online - Package Manager Preview以及新的构建系统。包管理器预览添加了许多构建步骤,包括“NuGet Publisher”步骤,该步骤应将包推送到由Visual Studio Online托管的私有源。

现在是documentation is a little out of step here。与documentation on authpersonal access tokens一样。有一些迹象表明,只要您设置了权限(构建服务帐户具有服务端点和包管理器扩展的权限),您就不需要在VSO和程序包管理器之间进行身份验证。实际的构建步骤会要求您从服务端点列表中进行选择,这就是我尝试过的。

当我在服务端点上没有放置凭据时,我收到错误:

Server Key must be set, set the password on the generic service

当我尝试将API密钥放在服务端点上时,它似乎在保存时被丢弃......并且错误更改为:

2015-11-18T08:35:24.5678951Z Invoking nuget with push C:\a\1\s\EventViewer\bin\Release\Project.Name.1.1.12.0.nupkg -s https://example.pkgs.visualstudio.com/DefaultCollection/_packaging/example/nuget/v3/index.json usfusmx4ez6mlfqwpp2abzc7e37denfcp7bxsep2hqij3tp4qwvq on C:\a\1\s\EventViewer\bin\Release\Project.Name.1.1.12.0.nupkg
2015-11-18T08:35:24.5688946Z C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\default\agent\worker\tools\NuGet.exe push C:\a\1\s\EventViewer\bin\Release\Project.Name.1.1.12.0.nupkg -s https://example.pkgs.visualstudio.com/DefaultCollection/_packaging/Example/nuget/v3/index.json usfusmx4ez6mlfqwpp2abzc7e37denfcp7bxsep2hqij3tp4qwvq
2015-11-18T08:35:25.3467312Z Please provide credentials for: https://example.pkgs.visualstudio.com/DefaultCollection/_packaging/Example/nuget/v3/index.json
2015-11-18T08:35:25.3667189Z ##[error]Object reference not set to an instance of an object.
2015-11-18T08:35:25.3677179Z UserName: Password: 
2015-11-18T08:35:25.4647059Z ##[error]Unexpected exit code 1 returned from tool NuGet.exe

我还试图使用个人访问令牌无济于事。

如何让发布步骤正常工作?

3 个答案:

答案 0 :(得分:4)

内置的NuGet Publish任务有两个选项:" external"饲料和内部"饲料。外部订阅源适用于第三方服务,如NuGet.org,Artifactory,并期望使用API​​密钥进行服务连接。

内部供稿是由Team Services托管的供稿。您可以添加Feed的NuGet端点的URL,而不是服务连接。构建系统依赖于项目集合构建服务(用于集合范围的构建定义)或项目构建服务(用于"此项目" - 构建定义)作为源的读者或贡献者。所有可用文档here

答案 1 :(得分:3)

更新:现在全部修复,因此您可以使用vNext中的标准打包步骤,它们就像魅力一样。

目前,我substituting the NuGet Publisher step with a PowerShell build step

这在“NuGet Packager”步骤之后进入构建,并允许我通过在暂停包之前设置包源来指定所有凭据。

$feedUrl = "https://example.pkgs.visualstudio.com/DefaultCollection/_packaging/Example/nuget/v3/index.json"

$packagePath =  $ENV:BUILD_REPOSITORY_LOCALPATH + "\YourOrg.YourComponent." + $ENV:BUILD_BUILDNUMBER + ".nupkg"

Write-Host "Adding package Source"
$addSourceCommand = $ENV:BUILD_REPOSITORY_LOCALPATH + "\nuget sources add -name ""Example"" -source " + $feedUrl + " -username ""your.username"" -password ""yourpassword"""
Invoke-Expression -Command $addSourceCommand

Write-Host "Pushing package to NuGet"
$pushCommand =  $ENV:BUILD_REPOSITORY_LOCALPATH + "\nuget push $packagePath -Source " + $feedUrl + " -ApiKey Example"
Invoke-Expression -Command $pushCommand

答案 2 :(得分:0)

我在这里登陆是因为我正在研究/配置内部部署 - 我正在运行自己的NuGet服务器(nuget.server,而不是visual studio online)。错误是相同的(或有相似的文字):

  

对象引用未设置为对象的实例

事实证明,我的解决方案是网址不对。 正确的版本是:http://server-name/NuGet/api/v2/package

为了完整起见,我有:http://server-name/NuGet/这是错误的。