Powershell Find-Package 命令不适用于 nuget v3 包源 [英] Powershell Find-Package command doesn't work with nuget v3 package source

查看:52
本文介绍了Powershell Find-Package 命令不适用于 nuget v3 包源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说,我不能在 nuget v3 url 中使用 Find-Package 命令:

As the title says I cannot use the Find-Package command with the nuget v3 url:

https://api.nuget.org/v3/index.json

如果我运行命令:

Find-Package nuget.versioning -Source https://api.nuget.org/v3/index.json

我收到一个错误,提示找不到匹配项.将命令更改为:

I get an error that no match was found. Changing the command to:

Find-Package nuget.versioning -Source https://www.nuget.org/api/v2

工作正常.

我是否需要升级某些软件才能使其正常工作?我正在运行 Powershell 版本 5,所以我不确定我需要采取哪些步骤来解决这个问题.

Do I need to upgrade some software to get this to work? I'm running Powershell version 5 so I'm not sure what steps I need to take to fix this.

推荐答案

使用 Powershell 5.1,它会按照您的描述失败.但是使用 PowerShell Core 7,它可以正常工作:

With Powershell 5.1, it fails as you described. But with PowerShell Core 7, it works correctly:

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 版本:

Note that you can check for your PowerShell version through the PSVersionTable variable:

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.

On PowerShell Core 7, you will see that it uses version 3 of the NuGet package provider, thus it supports 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 包源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆