OneGet / oneget

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

Problem using Nuget Repository #172

Closed leinad13 closed 8 years ago

leinad13 commented 8 years ago

Apologies if this question is a bit naive.

I want to install the library "Microsoft.Experimental.IO" from here.

Am I correct in saying that I should be able to add nuget.org as a provider and install this package using PackageManagement? If so, it doesnt seem to be working.

So I added a new PackageSource for nuget.org and then used Find-Package to ensure that the new repo was loaded and I could find the package. This works...

However when I try to install, it looks like it is searching the wrong repo and failing to install?

find-package Microsoft.Experimental.IO

Name                           Version          Source                         Summary
----                           -------          ------                         -------
Microsoft.Experimental.IO      1.0.0.0          Nuget.Org                      This library provides functionality to make it easier to work with paths that are longer than the current 259 character limit.`

Install-Package Microsoft.Experimental.IO

Install-Package : No match was found for the specified search criteria and package name 'Microsoft.Experimental.IO'.
At line:1 char:1
+ Install-Package Microsoft.Experimental.IO

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Install-Package Microsoft.Experimental.IO -verbose
VERBOSE: Skipping package provider provider 'NuGet'-- missing required option 'Destination'
VERBOSE: Using the provider 'Programs' for searching packages.
VERBOSE: Using the provider 'msu' for searching packages.
VERBOSE: Using the provider 'msi' for searching packages.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Microsoft.Experimental.IO'' for ''.
VERBOSE: Total package yield:'0' for the specified package 'Microsoft.Experimental.IO'.
Install-Package : No match was found for the specified search criteria and package name 'Microsoft.Experimental.IO'.
At line:1 char:1
+ Install-Package Microsoft.Experimental.IO -verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
KirkMunro commented 8 years ago

That's a bad error message. Try again with Install-Package, but include the -Destination pathWhereYouWantToInstallIt parameter.

quoctruong commented 8 years ago

@leinad13 Hi Leinad, do you know which version of NuGetProvider you are using? You can check for this with "Get-PackageProvider NuGet". Currently you have to use Destination parameter whenever calling Install-Package but we are publishing a newer version of NuGetProvider where Destination is not a required parameter so stay tuned!

quoctruong commented 8 years ago

@leinad13 The latest version of NuGetProvider is now available. You can update with Install-PackageProvider NuGet -Force

jianyunt commented 8 years ago

@leinad13, The latest (2.8.5.204) version of nugetprovider should have a better error message. Also the destination becomes an optional parameter. So we consider this is issue is fixed. Close now. Please free to reactivate it if still does not work you. thx!

dragosv commented 7 years ago

For me it fails completely. Any I've also tried other nuget packages and no dice as well.

VERBOSE: Using the provider 'NuGet' for searching packages.
VERBOSE: Searching repository 'https://api.nuget.org/v3/index.json/FindPackagesById()?id='Microsoft.Experimental.IO'' for ''.
install-package : No match was found for the specified search criteria and package name
'Microsoft.Experimental.IO'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
install-package -verbose -Name Microsoft.Experimental.IO -Destination ...
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception + FullyQualifiedErrorId NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
jianyunt commented 7 years ago

@dragosv I can not repro your scenario. See steps below. NuGet works fine with https://www.nuget.org/api/v2/. Which source location are you registering to?

PS C:\WINDOWS\system32> get-packageprovider nuget

Name                     Version          DynamicOptions
----                     -------          --------------
NuGet                    2.8.5.207        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, Con...

PS C:\WINDOWS\system32> get-module -Name Packagemanagement

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.1.0.0    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider...}

PS C:\WINDOWS\system32> get-packagesource

Name                             ProviderName     IsTrusted  Location
----                             ------------     ---------  --------
nuget.org                        NuGet            False      https://www.nuget.org/api/v2/
PSGallery                        PowerShellGet    False      https://www.powershellgallery.com/api/v2/

PS C:\WINDOWS\system32> find-package Microsoft.Experimental.IO -Source https://www.nuget.org/api/v2/ -provider nuget

Name                           Version          Source           Summary
----                           -------          ------           -------
Microsoft.Experimental.IO      1.0.0.0          nuget.org        This library provides functionality to make it easier to work with paths that are longer th...

PS C:\WINDOWS\system32> install-package Microsoft.Experimental.IO -Source https://www.nuget.org/api/v2/ -provider nuget

The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'nuget.org'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y

Name                           Version          Source           Summary
----                           -------          ------           -------
Microsoft.Experimental.IO      1.0.0.0          nuget.org        This library provides functionality to make it easier to work with paths that are longer th...

PS C:\WINDOWS\system32> Get-Package Microsoft.Experimental.IO

Name                           Version          Source                           ProviderName
----                           -------          ------                           ------------
Microsoft.Experimental.IO      1.0.0.0          C:\Program Files\NuGet\Packag... NuGet
dragosv commented 7 years ago

So it looks like this is fixed by specifying -Source https://www.nuget.org/api/v2/ (Ex: Install-Package MSBuild.Microsoft.VisualStudio.Web.targets -MinimumVersion 14.0.0.3 -ProviderName nuget -Source https://www.nuget.org/api/v2/ -Force).

beatcracker commented 7 years ago

My 2¢.

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.0.10586.117
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0, 5.0.10586.117}
BuildVersion                   10.0.10586.117
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
Get-PackageProvider

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipValidate
PowerShellGet            1.1.2.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, Filter, Tag, Includes, DscResource, Rol...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent
Install-Package -Name nancy -ProviderName NuGet -Verbose

VERBOSE: Using the provider 'NuGet' for searching packages.
VERBOSE: Searching repository 'https://api.nuget.org/v3/index.json/FindPackagesById()?id='nancy'' for ''.
Install-Package : No match was found for the specified search criteria and package name 'nancy'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Install-Package -Name nancy -ProviderName NuGet -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
Install-Package -Name nancy -ProviderName NuGet -Source https://www.nuget.org/api/v2/ -Verbose

VERBOSE: Using the provider 'NuGet' for searching packages.
VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='nancy'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'nancy'.
VERBOSE: Performing the operation "Install Package" on target "Package 'Nancy' version '1.4.3' from 'https://www.nuget.org/api/v2/'.".
VERBOSE: Searching repository 'https://www.nuget.org/api/v2/FindPackagesById()?id='Nancy'' for ''.
VERBOSE: InstallPackage' - name='Nancy', version='1.4.3',destination='C:\Program Files\PackageManagement\NuGet\Packages'
VERBOSE: DownloadPackage' - name='Nancy', version='1.4.3',destination='C:\Program Files\PackageManagement\NuGet\Packages\Nancy.1.4.3\Nancy.1.4.3.nupkg', uri='https://www.nuget.org/api/v2/package/Nancy/1.4.3'
VERBOSE: Downloading 'https://www.nuget.org/api/v2/package/Nancy/1.4.3'.
VERBOSE: Completed downloading 'https://www.nuget.org/api/v2/package/Nancy/1.4.3'.
VERBOSE: Completed downloading 'Nancy'.
VERBOSE: Hash for package 'Nancy' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='Nancy', version='1.4.3',destination='C:\Program Files\PackageManagement\NuGet\Packages'

Name                           Version          Source                           Summary
----                           -------          ------                           -------
Nancy                          1.4.3            https://www.nuget.org/api/v2/    Nancy is a lightweight web framework for the .Net platform, inspired by Sinatra. Nancy aim at deliverin...
jianyunt commented 7 years ago

Correct. The NuGet provider only supports V2.