OneGet / oneget

PackageManagement (aka OneGet) is a package manager for Windows
MIT License
2.38k stars 190 forks source link

Unable to download NuGet Provider on Win 7 SP1 x64 #301

Open brywang-msft opened 7 years ago

brywang-msft commented 7 years ago

Forked from comment: https://github.com/OneGet/oneget/issues/195#issuecomment-308863200

Gist of the issue:

LOCALHOST user C:/Users/user/Downloads # Update-Module -verbose PSReadline

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\user\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider byrunning 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to installand import the NuGet provider now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y
VERBOSE: Installing NuGet provider.
VERBOSE: Using the provider 'Bootstrap' for searching packages.
VERBOSE: Finding the package 'Bootstrap::FindPackage' 'NuGet','','2.8.5.201','''.
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '2' more times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '1' more times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '0' more times.
WARNING: Unable to download the list of available providers. Check your internet connection.

Action items:

brywang-msft commented 7 years ago

@rmenessec github.com/brywang-msft/oneget (branch downloaderrorlogging)* has a prototype for full CLR. Would you mind trying that version please? With -Debug enabled you should (hopefully) see a message like "Download failed: < error >". I would also enable -Verbose.

You'd have to build the module yourself (run src\bootstrap.ps1, then src\build.ps1 -framework net451).

If you want us to build the module, we can do that (maybe).

Thanks for helping us root cause this issue so we can prioritize this properly.

*have to put the prototype code here as the WIP of OneGet/OneGet is waiting for 1.1.6 release features to be merged.

rmenessec commented 7 years ago

I'm not familiar with building .NET source or PowerShell components. I do have MSVS2015 installed, mostly to build a few simple projects with optimizations (PuTTY, for example). What are the requirements for building OneGet? What are the steps?

If it's not relatively straightforward, or requires installing a lot of additional tools, I would prefer not to invest too much time learning my way around a build environment for OneGet.

brywang-msft commented 7 years ago

The build uses dotnet.exe, which is bootstrapped by build scripts. The instructions are provided in the readme, but for quick reference: (Open PowerShell)

 cd <clone>\src
# download the dotnet cli tool
 .\bootstrap.ps1

# building OneGet for fullclr
.\build.ps1 net451

# The built version is under <clone>\src\out\PackageManagement
# Note this module is not signed
# Pay attention to the module version in PackageManagement.psd1
# If it conflicts with a version you already have installed,
# feel free to change it.
# Finally, restart the PowerShell session if PackageManagement is already loaded (Get-Module)
Import-Module <clone>\src\out\PackageManagement\PackageManagement.psd1

I only included the PowerShell 5.1 build here as I assume that's what you'll need. If you want to be safe, you can replace net451 with netstandard1.6 and netcoreapp2.0 (calling build.ps1 3 times in total).

I'm not 100% sure of the requirements, but if you're on Win10 you should be fine. Older versions of Windows like Win7 need to install an optional update.

rmenessec commented 7 years ago

Win7. I'll be building and testing on the same machine that's experiencing the download problems. The bootstrap has already completed without visible errors. I just remembered: I already have .NET 4.7 and the corresponding SDK installed, for what that's worth. Does that affect the build string?

... '.\build.ps1 net47' ?

What about capturing the output? Will that be stored automatically, or do I need to capture with console redirection?

brywang-msft commented 7 years ago

No, no effect. It might not work on your Win7 setup, but you can give it a shot. Once the change is in the WIP branch (we're in the middle of small release to unblock a change in PowerShell Core), I'll see if I can get a .zip or something for you to try. Not sure how Jianyun usually gives out private builds.

rmenessec commented 7 years ago

What about capturing the output? Will that be stored automatically, or do I need to capture with console redirection?

brywang-msft commented 7 years ago

The output should go to standard out and error, so you should be able to use whatever method you find appropriate for redirection.

jeernest commented 7 years ago

I have the same issue:

> Find-PackageProvider Nuget -Verbose
VERBOSE: Using the provider 'Bootstrap' for searching packages.
VERBOSE: Finding the package 'Bootstrap::FindPackage' 'Nuget','','','''.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409',
retrying for '2' more times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409',
retrying for '1' more times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409',
retrying for '0' more times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409',
retrying for '2' more times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409',
retrying for '1' more times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409',
retrying for '0' more times.
WARNING: Unable to download the list of available providers. Check your internet connection.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the
registered repositories.
Find-PackageProvider : No match was found for the specified search criteria and package name
'Nuget'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Find-PackageProvider Nuget -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...PackageProvider:FindPackage
   Provider) [Find-PackageProvider], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement
   .Cmdlets.FindPackageProvider

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.15063.502
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.502
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

> [System.Environment]::OSVersion

Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.15063.0 Microsoft Windows NT 10.0.15063.0
lukespragg commented 6 years ago

Also noticing this issue on Windows 10.

PS E:\Projects> Install-PackageProvider NuGet -Verbose
VERBOSE: Using the provider 'Bootstrap' for searching packages.
VERBOSE: Finding the package 'Bootstrap::FindPackage' 'NuGet','','','''.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '2' more
times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '1' more
times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '0' more
times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '2' more
times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '1' more
times.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '0' more
times.
WARNING: Unable to download the list of available providers. Check your internet connection.
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.
At line:1 char:1
+ Install-PackageProvider NuGet -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-Pac
   kageProvider], Exception
    + FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackagePro
   vider

PS E:\Projects> Get-PackageProvider -debug -verbose

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
PowerShellGet            1.0.0.1          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

PS E:\Projects> Install-PackageProvider NuGet -Verbose
VERBOSE: Using the provider 'Bootstrap' for searching packages.
VERBOSE: Finding the package 'Bootstrap::FindPackage' 'NuGet','','','''.
VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '2' more
times.
PS E:\Projects> $PSVersiontable

Name                           Value
----                           -----
PSVersion                      5.1.15063.674
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.674
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
colteng1141 commented 6 years ago

I was experiencing the same issue with Windows 10 Enterprise, running the commands in Visual Studio Code. I was able to successfully install NuGet and the module I was truly after by using the built-in Powershell ISE as an administrator.

However, I'm still unable to install subsequent modules via Visual Studio Code. It's saying it is unable to resolve package source 'https://www.powershellgallery.com/api/v2/'. This may be another issue though.

shurick81 commented 5 years ago

I noticed that on the machines where the package provider is installed properly, I can run this download command without issues:

(New-Object System.Net.WebClient).DownloadFile('https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', 'C:\Temp\providers.masterList.feed.swidtag')

However, on those machines that have issues with installing the package provider, this downloading command generates the following error:

Exception calling "DownloadFile" with "2" argument(s): "The underlying
connection was closed: Could not establish trust relationship for the SSL/TLS
secure channel."
At line:1 char:1
+ (New-Object System.Net.WebClient).DownloadFile('https://go.microsoft. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException

Can you see the same correlation on your side? Can anyone suggest the solution?

OraDotNetDev commented 5 years ago

I know this is an old issue but @shurick81 have you tried the following to enable TLS 1.2 for the session?