Search code examples
nugetmsbuild-task

Force NuGet Commandline List to NOT use Wildcards


I'm trying to use the NuGet command line to get the latest version of a package in a repo as part of an MSBuild task. Unfortunately there are three packages which all start with the same thing, for example:

MyCorp.ThirdPartyServices
MyCorp.ThirdPartyServices.DB
MyCorp.ThirdPartyServices.OtherStuff

Therefore the command

nuget.exe list -Source http://mycorp.repo/nuget MyCorp.ThirdPartyServices

Returns all three entries as I'm assuming it's internally adding a wildcard to the end of the search term. Whilst I can deal with this, I'd rather not have to. Is there any way to search for an exact package name or do I just have to suck it up and parse whatever comes out?


Solution

  • You should be able to use a special search syntax to filter the result. The following works on nuget.org:

    nuget.exe list packageid:NUnit
    

    This just returns the single NUnit package.

    Here I am using NuGet v2.