无法在 Linux 上的 PowerShell Core 中安装 NuGet 包提供程序

编程入门 行业动态 更新时间:2024-10-23 21:38:32
本文介绍了无法在 Linux 上的 PowerShell Core 中安装 NuGet 包提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试在 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 包提供程序

本文发布于:2023-11-16 11:14:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1603771.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序   PowerShell   Linux   NuGet   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!