title: How can I get the NuGet package version programmatically from a NuGet feed?
body: <p>First off, of all the NuGet code, I'm trying to figure out which one to reference.</p>
  <p>The main question is, given a NuGet <em>package name</em>, is there a programmatic way to retrieve the versions from the NuGet feed and also the latest version for general consumption?</p>
  <p>For example, given a package name of ILMerge, it would be nice to get the latest package version of 2.13.307.</p>
  <pre><code>// Pseudo code, makes a lot of assumptions about NuGet programmatic interfaces
  PackageRef currentVersion = nugetlib.getpackageinfo(args[0]);
  Console.WriteLine(&quot;Package Id: '{0}':&quot;, pkg.Id);
  Console.WriteLine(&quot;  Current version: {0}&quot;, pkg.Version);
  Console.WriteLine(&quot;  Available versions: {0}&quot;, String.Join(&quot;,&quot;,pkg.Versions.Select(_=&gt;_)));
  </code></pre>