Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read metadata from nupkg

Tags:

c#

.net

nuget

Is there anyway to read the metadata of a NuGet-package-file?

I would really like to create a simple site for searching among my nupkg-files..

Thanks in advance!

like image 525
Inx Avatar asked Oct 30 '12 12:10

Inx


People also ask

How do I unpack a Nupkg file?

Extracting Nupkg files using command line Or just simply extract package with zip either by opening it in zip or by changing extension to . zip and just extracting it.

How do I open a Nupkg file in Windows?

Menu Tools → Options → Package Manager Give a name and folder location. Click OK. Drop your NuGet package files in that folder. Go to your Project in Solution Explorer, right click and select "Manage NuGet Packages".

What is package metadata?

Package metadata describes a package for its consumers: who wrote it, where its repository is, and what versions of it have been published. It also contains a description of each version of a package present in the registry, listing its dependencies, giving the url of its tarball, and so on.


1 Answers

The NuGet.Core package contains the official API for reading package metadata.

To read information about a single .nupkg file use code similar to following.

var myPackage = new ZipPackage(@"C:\Path\to\MyPackage.1.0.0.nupkg");

Console.WriteLine("Id: {0}", myPackage.Id);
Console.WriteLine("Version: {0}", myPackage.Version);
Console.WriteLine(
    "Assemblies: {0}",
    myPackage.AssemblyReferences.Select(a => a.Name).ToArray());

There are also similar classes for reading Package sources (aka Feeds), etc.

like image 196
bricelam Avatar answered Sep 29 '22 15:09

bricelam