SirPentor
SirPentor

Reputation: 2044

Why can Find-Package not find a package by name on my local package source

I have a local package source to mess around with some things. I created a brain-dead package called CoolUtils, adding it using nuget add. You can find it using nuget:

PS> nuget list -source E:\nuget-repo-test-01\
CoolUtils 2.0.20171024.1

PS> nuget list coolutils -source E:\nuget-repo-test-01\
CoolUtils 2.0.20171024.1

However, Find-Package can't find it by name, but can find it with wildcards or no name specified:

PS> Find-Package -Source E:\nuget-repo-test-01\

Name                           Version          Source                           Summary
----                           -------          ------                           -------
CoolUtils                      2.0.20171024.1   E:\nuget-repo-test-01\           Test package with dumb scripts.

PS> Find-Package *cool* -Source E:\nuget-repo-test-01\

Name                           Version          Source                           Summary
----                           -------          ------                           -------
CoolUtils                      2.0.20171024.1   E:\nuget-repo-test-01\           Test package with dumb scripts.

PS> Find-Package CoolUtils -Source E:\nuget-repo-test-01\
Find-Package : No match was found for the specified search criteria and package name 'CoolUtils'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Find-Package CoolUtils -Source E:\nuget-repo-test-01\
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...ets.FindPackage:FindPackage) [Find-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage

I also can't install it using Install-Package, though I can using nuget.

Upvotes: 4

Views: 4089

Answers (2)

Mattias
Mattias

Reputation: 1

I experienced the same issue and managed to solve it by moving the .nupkg file to the root of the registered local package source, i.e. "C:\projects\packages\"

PS> Get-PackageSource -Name Local

Name                             ProviderName     IsTrusted  Location
----                             ------------     ---------  --------
Local                            NuGet            False      C:\projects\packages\

PS> Find-Package -Source Local -Name TestCmdlet

Name                           Version          Source           Summary
----                           -------          ------           -------
TestCmdlet                     1.0.0            Local            Package Description

Upvotes: 0

maoizm
maoizm

Reputation: 729

Cmdlet Find-Package is part of PackageManagement module, while Nuget.exe is one of a dozen of package providers for PackageManagement module.

An analogy (not fully correct) is an application and plugins: Nuget is like one of plug-ins which provides functionality to its application (Find-Package, Install-Package and other cmdlets from PackageManagement).

Despite Nuget can do some package management tasks, in order to work under control of standardized PackageManagement commands you should properly declare ("register") nuget's package locations to make them known for PackageManagement:

Register-PackageSource -name MyPackages -location E:\nuget-repo-test-01 -provider Nuget


Now Find-Package can search and Install-Package can install packages from newly registered package source. Full list of known package sources can be retrieved by

Get-PackageSource

Upvotes: 5

Related Questions