Search code examples
c#nugetnuget-spec

Programmatically read NuSpec file with NuGet.Core


While it is possible to read a nupkg file with new ZipPackage("local/path//to/my/nupkgfile"). ZipPackage is a class in the NuGet.Core nuget package.

I would like to know if there is another class in this library that allows me to read the nuspec xml file.

What would be the best way to do this?


Solution

  • There is the Manifest class which is used to read the .nuspec file.

    The ZipPackage does not directly give you access to the Manifest. Information from the Manifest is available as properties on the ZipPackage class. So I would look at the information available on the ZipPackage if you are using that class. Otherwise you will have to locate the .nuspec file after extracting it from the .nupkg.