无法从Azure DevOps Artifact Feed访问Chocolatey程序包

时间:2019-09-08 03:24:21

标签: azure-devops nuget chocolatey

正在执行的代码已推送到Azure DevOps工件提要:

schily-cdrtools

使用nuget.exe推送nuget程序包并下载工作没有问题:

nuget.exe push -Source "cdrtools-artifacts" -ApiKey AzureDevOps schily-cdrtools.3.2.1.nupkg

nuget.exe install -Source "cdrtools-artifacts" schily-cdrtools 

但是,尝试使用v2或v3 nuget注册向Chocolatey注册此源会导致404错误:

choco source add -n=schily-artifacts `
>>    -s="https://flapjacks.pkgs.visualstudio.com/_packaging/schily-artifacts/nuget/v3/index.json" `
>>    -u="xxxxxxxx" -p="xxxxxxxxxxx"

 Error retrieving packages from source 'https://flapjacks.visualstudio.com/_packaging/schily-artifacts/nuget/v3/index.json':
 The remote server returned an error: (404) Not Found.
 schily-cdrtools not installed. The package was not found with the source(s) listed.
 Source(s): 'https://flapjacks.visualstudio.com/_packaging/schily-artifacts/nuget/v3/index.json'
 NOTE: When you specify explicit sources, it overrides default sources.
 If the package version is a prerelease and you didn't specify `--pre`,
 the package may not be found.
 Please see https://chocolatey.org/docs/troubleshooting for more
 assistance.

...以及使用v2时出现的404错误:

choco source add -n=schily-artifacts `
>>    -s="https://flapjacks.pkgs.visualstudio.com/_packaging/schily-artifacts/nuget/v2" `
>>    -u="xxxxxxxx" -p="xxxxxxx"

尝试使用v2注册列出列表时,没有找到任何软件包,但是,当使用v3运行choco列表时,它会返回404错误。

最后,尝试安装软件包失败并出现凭据问题:

Install-Package schily-cdrtools
WARNING: Cannot access 'https://flapjacks.pkgs.visualstudio.com/_packaging/schily-artifacts/nuget/v3/index.json'. Are you missing 'Credential' parameter in the cmdlet?

Install-Package : No match was found for the specified search criteria and package name 'schily-cdrtools'. Try Get-Packa
geSource to see all available registered package sources.
At line:1 char:1
+ Install-Package schily-cdrtools
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Microsoft.PowerShel\u2026lets.InstallPackage:InstallPackage) [Install-Package
], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

有什么主意,我缺少什么?

我一直在使用以下内容作为指导:

https://blog.pauby.com/post/chocolatey-repository-using-azure-devops-artifacts-feed/

2 个答案:

答案 0 :(得分:0)

PackageManagement cmdlet当前已损坏,因此使用不带var dateUtc = TimeZoneInfo.ConvertTimeToUtc(date); 参数的Install-Package将会失败。您需要将-Credential参数添加到所有PackageManagement cmdlet中,以使其起作用。

如果我跑步(完全):

-Credential

然后我得到:

choco source add -n=schily-artifacts -s="https://flapjacks.pkgs.visualstudio.com/_packaging/schily-artifacts/nuget/v2" -u="xxxxxxxx" -p="xxxxxxxxxxx"

在使用Feed之前,巧克力不会对其进行验证:

Chocolatey v0.10.15
Added schily-artifacts - https://flapjacks.pkgs.visualstudio.com/_packaging/schily-artifacts/nuget/v2 (Priority 0)

这是我期望的(因为凭据无效)。因此,我不确定添加源时您的错误来自哪里。

答案 1 :(得分:0)

  

无法从Azure DevOps Artifact Feed访问Chocolatey程序包

根据该指南中的步骤创建示例后,我无法重现此问题。但我想为您提供一些故障排除方法:

  1. 检查您的Chocolatey版本,我的是Chocolatey v0.10.15
  2. 添加名为源的Chocolatey Azure DevOps Feed时,请使用PAT代替密码。
  3. 使用管理员运行命令行。
  4. 命令行应完整且不需要分支,例如:

    choco source add -n=MyCustomFeed -s="https://pkgs.dev.azure.com/<MyOrgName>/_packaging/<FeedName>/nuget/v2" -u="MyAccount.com" -p="PAT"
    

我的测试结果:

enter image description here

enter image description here

希望这会有所帮助。