【问题标题】:How to fix Nuget Provider "Find-Module" Installation error with PowerShell 7.3?How to fix Nuget Provider \"Find-Module\" Installation error with PowerShell 7.3?
【发布时间】:2022-12-02 04:08:29
【问题描述】:

I've been trying to run a PowerShell script, and upon doing so, I receive a message that NuGet Provider is required.

NuGet provider is required to continue
This version of PowerShellGet requires minimum version '2.8.5.201' of NuGet provider to publish an item to NuGet-based
repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\timothy.granata\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider
by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install
 and import the NuGet provider now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):

If I input Y, an error is returned:

Find-Module: NuGet provider is required to interact with NuGet-based repositories. Please ensure that '2.8.5.201' or newer version of NuGet provider is installed.

If I try running Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force as it recommends, I also get an error:

Install-PackageProvider: Unable to find repository with SourceLocation ''. Use Get-PSRepository to see all available repositories.

And finally, if I run Get-PSRepository, that also errors:

Get-PackageSource: Unable to find module providers (PowerShellGet).

I have tried:

  • Reinstalling PowerShell 7
  • Making sure I am using TLS 1.2 by running [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  • Running PowerShell as Administrator
  • Deleting the Modules folder found in my C:\Users<user>\Documents\WindowsPowerShell folder

I'm unsure what else I can try at this point. How can I install the NuGet provider for use with PowerShell 7.3?

【问题讨论】:

    标签: powershell nuget powershell-7.0 powershell-7.3


    【解决方案1】:

    Try

    $sourceArgs = @{
        Name = 'nuget.org'
        Location = 'https://api.nuget.org/v3/index.json'
        ProviderName = 'NuGet'
    }
    
    Register-PackageSource @sourceArgs
    
    Get-PackageProvider | where name -eq 'nuget' | Install-PackageProvider
    

    【讨论】:

      猜你喜欢
      • 2022-12-27
      • 2022-12-19
      • 2022-12-26
      • 2022-12-01
      • 2023-02-25
      • 2022-12-27
      • 2022-12-27
      • 2022-12-28
      • 2022-12-02
      相关资源
      最近更新 更多