Can't figure out how to get target framework version of a package via NuGet API?

Topics: General
Mar 5, 2013 at 9:47 AM
Edited Mar 5, 2013 at 9:54 AM
My first thought was it's a pretty simple question - turned out that it's not. Or I missed something.
For a little bit of tooling I'm writing, I need to figure out target framework version (3.5, 4.0, etc.) of a package, given it's id and version. So far, no success. I referenced NuGet executable to get access to the API, and I assume NuGet.Core package does pretty much the same thing.
My understanding was that it should be hidden somewhere behind IPackageMetadata interface, but I couldn't find it so far.
I tried:
  • IPackageMetadata.FrameworkAssemblies - seems to always be an empty array;
  • PackageDependencySet.TargetFramework and SupportedFramework properties - same result, "Enumeration yielded no results".
    So, is there a way to do it via API? If there isn't one, I'd be happy to do a pull request if someone can point me in the right direction.
    P.S. Having TargetFrameworkProfile (e.g. Full, Client) would also be nice.
Mar 5, 2013 at 5:03 PM
Given this example from the OData feed, I would say its done strictly on the client side by inspecting the actual package:
    <title type="text">32feet.NET.Phone</title>
    <summary type="text">32feet.NET - Personal Area Networking for .NET</summary>
      <name>Peter Foot, Alan McFarlane</name>
    <link rel="edit-media" title="V2FeedPackage" href="Packages(Id='32feet.NET.Phone',Version='8.0.0')/$value" />
    <link rel="edit" title="V2FeedPackage" href="Packages(Id='32feet.NET.Phone',Version='8.0.0')" />
    <category term="NuGetGallery.V2FeedPackage" scheme="" />
    <content type="application/zip" src="" />
    <m:properties xmlns:m="" xmlns:d="">
      <d:Copyright>Copyright &amp;#x00A9; In The Hand Ltd 2003 - 2013</d:Copyright>
      <d:Created m:type="Edm.DateTime">2013-01-15T20:07:08.577</d:Created>
      <d:Description>32feet.NET for Windows Phone is a shared-source library to simplify Bluetooth development with Windows Phone 8.</d:Description>
      <d:DownloadCount m:type="Edm.Int32">178</d:DownloadCount>
      <d:IsLatestVersion m:type="Edm.Boolean">false</d:IsLatestVersion>
      <d:IsAbsoluteLatestVersion m:type="Edm.Boolean">false</d:IsAbsoluteLatestVersion>
      <d:IsPrerelease m:type="Edm.Boolean">false</d:IsPrerelease>
      <d:Language m:null="true"></d:Language>
      <d:Published m:type="Edm.DateTime">2013-01-15T20:07:09.22</d:Published>
      <d:PackageSize m:type="Edm.Int64">10779</d:PackageSize>
      <d:ReleaseNotes>Preview release of the new Windows Phone 8 version of the library.</d:ReleaseNotes>
      <d:RequireLicenseAcceptance m:type="Edm.Boolean">true</d:RequireLicenseAcceptance>
      <d:Tags xml:space="preserve"> Bluetooth </d:Tags>
      <d:VersionDownloadCount m:type="Edm.Int32">30</d:VersionDownloadCount>
Mar 5, 2013 at 5:24 PM
Edited Mar 5, 2013 at 5:27 PM
Great. So, to get info on 10 packages I need to download all the binaries (it will take time and traffic even with the fast network) and then do a directory search, mapping directories to framework versions.
What's even worse - every developer that want to do that in the future will search for the solution and then likely do the exact same thing. Even if I create NuGet package that does this, it won't do the justice.
I love Microsoft.
Thanks for clarification @ferventcoder - my above words shouldn't concern you. I'm just thinking out loud.
Mar 5, 2013 at 5:27 PM
To be fair just because it isn't there now in the metadata doesn't mean it shouldn't be there.
Mar 5, 2013 at 5:36 PM
Thanks for your love to Microsoft.
Mar 6, 2013 at 8:56 AM
But VS extension definitely has this information - if you want to install a package version that depends on 4.0 in a 3.5 project, you'll get an error.
So what is it - someone forgot to put it into API? That's private info, may be.