![](/img/trans.png)
[英]Powershell Find-Package fails with unable to resolve package source
[英]Powershell Find-Package command doesn't work with nuget v3 package source
正如標題所說,我不能在 nuget v3 url 中使用 Find-Package 命令:
https://api.nuget.org/v3/index.json
如果我運行命令:
Find-Package nuget.versioning -Source https://api.nuget.org/v3/index.json
我收到一個錯誤,提示找不到匹配項。 將命令更改為:
Find-Package nuget.versioning -Source https://www.nuget.org/api/v2
工作正常。
我是否需要升級某些軟件才能使其正常工作? 我正在運行 Powershell 版本 5,所以我不確定我需要采取哪些步驟來解決這個問題。
使用 Powershell 5.1,它會按照您的描述失敗。 但是使用 PowerShell Core 7,它可以正常工作:
PS> Find-Package nuget.versioning -Source https://api.nuget.org/v3/index.json -ProviderName NuGet
Name Version Source Summary
---- ------- ------ -------
NuGet.Versioning 4.6.4 nuget.org NuGet's implementation of Semantic Versioning.
請注意,您可以通過PSVersionTable
變量檢查您的 PowerShell 版本:
PS> $PSVersionTable
Name Value
---- -----
PSVersion 7.0.0
PSEdition Core
GitCommitId 7.0.0
OS Microsoft Windows 10.0.18362
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
在 PowerShell Core 7 上,您將看到它使用 NuGet 包提供程序的第 3 版,因此它支持協議 v3。
PS> Get-PackageProvider
Name Version DynamicOptions
---- ------- --------------
NuGet 3.0.0.1 Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipValidate
PowerShellGet 2.2.3.0 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, AllowPrereleaseVersions, Filter, Tag, Includes, DscResource, RoleCapability, Command, Accep…
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.