gpt4 book ai didi

Powershell Find-Package 命令不适用于 nuget v3 包源

转载 作者:行者123 更新时间:2023-12-02 22:22:56 26 4
gpt4 key购买 nike

正如标题所说,我不能将 Find-Package 命令与 nuget v3 url 一起使用:

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 核心 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 上,您将看到它使用版本 3 的 NuGet 包提供程序,因此它支持协议(protocol) 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…

关于Powershell Find-Package 命令不适用于 nuget v3 包源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54367822/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com