我正在尝试在 Linux 上的 PowerShell 7 中设置 NuGet 包提供程序,以便我可以使用Install-Package 从 NuGet 库获取包.但是,当我运行时:
I'm trying to set up the NuGet package provider on Linux in PowerShell 7 so I can useInstall-Package to get a package from the NuGet Gallery. However, when I run:
Install-PackageProvider -Name NuGet -Force我收到以下错误:
Install-PackageProvider: No match was found for the specified search criteria for the provider 'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package has the tags.我进行了一些搜索,并从该站点和其他发生此错误的站点中找到了一些问题,有些答案说我需要强制使用 TLS 1.2:
I did a bit of searching and found a few questions from this site and others where this error occurs, some answers saying I need to force TLS 1.2:
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12有人说要在Install-PackageSource上指定-RequiredVersion,有人说要使用-ForceBootstrap,有人说要使用 -Force.这些都不起作用,我每次仍然遇到相同的错误.Get-PackageProvider 将 NuGet 列为提供程序.
some saying to specify -RequiredVersion on Install-PackageSource, some saying to use-ForceBootstrap, and some saying to use -Force. None of these work and I'm still met with the same error each time. Get-PackageProvider lists NuGet as a provider.
我也无法使用 PowerShell Core 在 Windows 上安装 NuGet 提供程序,但出现相同错误.这是 PowerShell Core 不支持的吗?
I'm was also unable to install the NuGet provider on Windows using PowerShell Core with the same error. Is this just not supported from PowerShell Core?
推荐答案我也收到此错误并且指定版本(当前为 3.0.0.1)也失败.对我有用的是将 packageprovider 输送到 Install-PackageProvider
I also received this error and specifying the version (currently 3.0.0.1) also fails. What worked for me was piping the packageprovider into Install-PackageProvider
Get-PackageProvider | where name -eq 'nuget' | Install-PackageProvider您可以添加 -Force 如果您想避免对 包来自未标记为受信任的包源的回答是肯定的.您确定要从 '' 安装软件吗?
You may add -Force if you want to avoid answering yes to The package(s) come(s) from a package source that is not marked as trusted. Are you sure you want to install software from ''?
更多推荐
无法在 Linux 上的 PowerShell Core 中安装 NuGet 包提供程序
发布评论