Skip to content
This repository has been archived by the owner on Feb 20, 2021. It is now read-only.

Get-Package does not work with NuGet, but works when called by Install-Package ? #10

Open
Jaykul opened this issue Sep 23, 2015 · 3 comments

Comments

@Jaykul
Copy link

Jaykul commented Sep 23, 2015

For example, note in this trace that the second call to Install-Package correctly detects the package is already installed, but there's no way for me to get the information from the installed package (e.g. what source it came from), and the output of Install-Package doesn't even have the install location.

This is wrong ...

PS> $Package = @{ 
    Name = "Newtonsoft.Json"
    ProviderName = "NuGet"
    Source = "https://www.nuget.org/api/v2"
}

PS> $Options = @{
    Destination = $PWD
    ExcludeVersion = $true
    PackageSaveMode = "nuspec"
    Force = $true
    Verbose = $true
}

PS> Install-Package @Package @Options
VERBOSE: NuGet: Installing 'Newtonsoft.Json 7.0.1'.
VERBOSE: NuGet: Successfully installed 'Newtonsoft.Json 7.0.1'.

Name                           Version          Source           Summary
----                           -------          ------           -------
Newtonsoft.Json                7.0.1            NuGet

PS> Install-Package @Package @Options
VERBOSE: NuGet: Package "Newtonsoft.Json" is already installed.
VERBOSE: Skipped Package 'Newtonsoft.Json v7.0.1' already installed

PS> Get-Package @Package @Options
Get-Package : A parameter cannot be found that matches parameter name 'Source'.
At line:1 char:13
+ Get-Package @Package @Options
+             ~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-Package], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackage

PS> $Package.Remove("Source")
PS> Get-Package @Package @Options
Get-Package : No package found for  'Newtonsoft.Json'.
At line:1 char:1
+ Get-Package @Package @Options
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...lets.GetPackage:GetPackage) [Get-Package], Exception
    + FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackage
@quoctruong
Copy link

Hi Jay, Get-Package for nuget requires a destination parameter. That's why it didn't work. Have you tried Get-Package -ProviderName nuget -Destination ?

@Jaykul
Copy link
Author

Jaykul commented Sep 24, 2015

I definitely included the same Destination.

If you look at my sample code, you'll see I provided it the exact same parameter hashtable as I did to Install-Package (except that I had to remove the Source parameter).

@quoctruong
Copy link

Hi jay, sorry for overlooking that. We actually had a fix for this issue (just hasn't been released yet). Also, in the last community meeting, we have communicated to the community that we are rewriting our own nuget package provider so that it will run on nano server. We remove the PackageSaveMode option from the new nuget provider, will this affect your existing scripts?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants