0

I am trying to install the NuGet module using Powershell. Though I am running the PowerShell with admin access, I got this error:

    NuGet provider is required to continue
    PowerShellGet requires NuGet provider version '2.8.5.201' or newer to 
    interact with NuGet-based repositories. The NuGet provider must be 
    available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
    'C:\Users\Admin\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"): y
    WARNING: Unable to download the list of available providers. Check your 
    internet connection.
    PackageManagement\Install-PackageProvider : Unable to resolve package 
    reference 'https://onegetcdn.azureedge.net/providers/nuget- 
    2.8.5.208.package.swidtag'.
    At C:\Program 
    Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7468 
    char:21
    + ...     $null = PackageManagement\Install-PackageProvider -Name 
    $script:N ...
    +                 
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: 
    (https://onegetc...package.swidtag:String) [Install-PackageProvider], 
    Exception
    + 

FullyQualifiedErrorId:UnableToResolvePackage,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider

    PackageManagement\Import-PackageProvider: No match was found for the 
    specified search criteria and provider name 'NuGet'. Try 'Get- 
    PackageProvider -ListAvailable' to see if the provider exists on the 
    system.
    At C:\Program 
    Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7474 
    char:21
    + ...     $null = PackageManagement\Import-PackageProvider -Name 
    $script:Nu ...
    +                 
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (NuGet:String) [Import- 
    PackageProvider], Exception
    + FullyQualifiedErrorId : 

NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider
     
1
  • Are you on a network behind a corporate proxy server? Commented Jan 6, 2020 at 10:07

1 Answer 1

3

Try installing it like this if you're behind a corporate proxy - the first two additional lines will use your current credentials for subsequent cmdlets:

[System.Net.WebRequest]::DefaultWebProxy = [System.Net.WebRequest]::GetSystemWebProxy()
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
Install-PackageProvider -Name NuGet -MinimumVersion '2.8.5.201' -Force -Scope AllUsers

Or... you can use the -Proxy and -ProxyCredential switches for the Install-PackageProvider cmdlet.

Sign up to request clarification or add additional context in comments.

4 Comments

thank you for your efforts to help me...but I got an error while executing the last command The error is Install-PackageProvider: A positional parameter cannot be found that accepts argument '--MinimumVersion'.
What error? The same one? Did you try providing the -Proxy and -ProxyCredential switches instead? Are you behind a corporate proxy? Did you paste all 3 commands into ISE then run them or try running them one at a time?
Put the version string in quotes and try again - I've edited my answer above as there was a typo also, -MinimumVersion should have one '-' not two '--'.
For folks finding this answer nowadays, another piece of the puzzle I needed to resolve that error was setting the TLS version for subsequent commands. stackoverflow.com/a/61078227/3269584

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.