【问题标题】:Unable to install NuGet package provider on PowerShell Core 7.0.3无法在 PowerShell Core 7.0.3 上安装 NuGet 包提供程序
【发布时间】:2020-09-15 16:57:56
【问题描述】:

我在 Ubuntu 18.04 上有一个 PowerShell Core 7.0.3

尝试使用以下命令安装 NuGet 时,出现错误:

PS /home/adp/Downloads> Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-PackageProvider: Unable to find repository with SourceLocation ''. Use Get-PSRepository to see all available repositories.

Get-PSRepository 命令也不起作用:

PS /home/adp/Downloads> Get-PSRepository 
Get-PackageSource: /home/adp/.local/share/powershell/Modules/PowerShellGet/2.1.2/PSModule.psm1:9186
Line |
9186 |  … ckageSources = PackageManagement\Get-PackageSource @PSBoundParameters
     |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Unable to find module providers (PowerShellGet).

而且,Get-PackageProvider -ListAvailable 什么也不返回。

我也试过this solution,还是不行。

我被困在这个问题上,感谢任何帮助。

【问题讨论】:

  • 你是说你试过Get-PackageProvider | where name -eq 'nuget' | Install-PackageProvider $sourceArgs = @{ Name = 'nuget.org' Location = 'https://www.nuget.org/api/v2' ProviderName = 'NuGet' } Register-PackageSource @sourceArgs但没用?它做了什么?
  • @DougMaurer 非常感谢您的回答。 Get-PackageProvider | where name -eq 'nuget' | Install-PackageProvider 返回Install-PackageProvider: Unable to find repository with SourceLocation ''. Use Get-PSRepository to see all available repositories.
  • 并且,$sourceArgs = @{ Name = 'nuget.org' Location = 'nuget.org/api/v2' ProviderName = 'NuGet' } Register-PackageSource @sourceArgs 返回Register-PackageSource: Unable to find package providers (NuGet).
  • Get-PackageSource 显示什么?
  • 变成Get-PackageSource: Unable to find package providers ().

标签: nuget powershell-core


【解决方案1】:

删除\Documents\WindowsPowershell\ 下的Modules 文件夹对我们有用 (source)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-11
    • 1970-01-01
    • 1970-01-01
    • 2022-06-11
    • 1970-01-01
    • 2022-07-04
    • 1970-01-01
    • 2018-12-26
    相关资源
    最近更新 更多