Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerShell NuGet - "no match was found for the specified search criteria", "unable to find dependent packages", etc

I was trying to install the assembly System.IdentityModel.Tokens.Jwt, but I keep getting nuget errors:

find-package : No match was found for the specified search criteria and package name 'System.IdentityModel.Tokens.Jwt'. Try Get-PackageSource to see all available registered package sources.

When I download the .nupkg file directly and try to install it that way, I get the following error:

Install-Package : Unable to find dependent package(s) (Microsoft.IdentityModel.Tokens)

What am I doing wrong? I am a linux person normally so my instinct is that I am lacking the appropriate repositories, but I couldn't figure out how to resolve that issue.

like image 434
user8773136 Avatar asked Feb 21 '18 18:02

user8773136


1 Answers

That was a bit difficult to find, but here is my solution. If the Get-PackageSource tells you that there is no NuGet registered as a package source then we register it first:

Register-PackageSource -provider NuGet -name nugetRepository -location https://www.nuget.org/api/v2

After that it should work.

I had another issue though. I did have NuGet registered but apparently, this PowerShell cmdlet expects to work with the v2 API version of NuGet, while I had v3 registered. There are 2 solutions to that: either re-register the correct version, for that

Unregister-PackageSource -Name nuget.org (check the name first) and then register the correct version using the earlier command

OR

specify the correct API version in the Find (and other) commands explicitly:

Find-Package System.IdentityModel.Tokens.Jwt -Source https://www.nuget.org/api/v2. There is an issue on Gihub that provides this solution.

like image 59
Andrey Stukalin Avatar answered Oct 24 '22 10:10

Andrey Stukalin