问题
我想从公共存储库中安装一个包。我希望使用PackageSource External
。这是一个Azure DevOps Artifacts Feed,配置了NuGet Gallery作为上游源
。由于NuGet Gallery是一个上游源,因此我的包请求应该通过Artifacts传递并由上游源满足,但实际上出现错误,指出没有匹配项。
另一方面,如果我使用直接指向NuGet Gallery的PackageSource提交相同的请求,则可以正常工作。是否Artifacts中的Upstream source功能有问题?
包源
[D:\MySandboxes\TFS\Development\DevOps\]
>Get-PackageSource
Name ProviderName IsTrusted Location
---- ------------ --------- --------
Microsoft Visual Studio Offli... NuGet False C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Internal NuGet False http://azuredevops/Development/_packaging/Internal/nuget/v3/index.json
External NuGet False http://azuredevops/Development/_packaging/External/nuget/v3/index.json
MyNuGet NuGet False https://www.nuget.org/api/v2
PSGallery PowerShellGet False https://www.powershellgallery.com/api/v2
使用Azure DevOps Artifacts软件包源安装软件包(失败)
[D:\MySandboxes\TFS\Development\DevOps\]
>Install-Package Resta.UriTemplates -Source External -Destination "."
Install-Package : No match was found for the specified search criteria and package name 'Resta.UriTemplates'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Install-Package Resta.UriTemplates -Source External -Destination "."
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
使用NuGet Gallery包源安装软件包(成功)
[D:\MySandboxes\TFS\Development\DevOps\]
>Install-Package Resta.UriTemplates -Source MyNuGet -Destination "."
The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'MyNuGet'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "No"): a
Name Version Source Summary
---- ------- ------ -------
Resta.UriTemplates 1.3.0 MyNuGet .NET implementation of the URI template spec (RFC6570). Supports up to level 4 template expressions.
nuget.exe
命令来安装包,现在似乎可以正常工作了。我猜测我的Install-Package
cmdlet可能是一个旧版本,有点难搞。我将把这个问题写成答案,但我仍然不完全确定为什么Install-Package
失败而nuget.exe install
却能成功。 - Zam