Programmatically generate a NuGet package without NuGet.Core

613 Views Asked by At

I'm looking to generate a .nupkg containing a [single] [source] file on the fly without using the NuGet.Core lib or shelling out to a nuget.exe pack.

As I understand it, in essence to generate a .nupkg with a single file in it should be a matter of the following 'simple steps' in the creation of an Open Package Format file:

  1. Validate the nuspec (It'll be programattically generated, but it'd be nice to know the outputs from such a lib / phase of processing are 'clean')
  2. Include the .nuspec as a file in the Package (no signatures or manipulation required)
  3. Include the file being linked in the Package in the location mentioned in the .nuspec

I'd appreciate it if anyone can fill me in on any missing steps that a nuget pack commandline would do (does anything need to be signed, etc.)

Validation that I'm not missing anything in the steps above is the most valuable, though code would be no harm either.


A bit more context: For now, the downstream consumers are solely code that's part of the same codebase (which also does not use NuGet.Core). It's not important now but, over time, its conceivable that it might be desirable for VS and/or third party tools to be able to introspect into the generated packages.

Additional context.

[Via @bricelam]: .nupkg files are standard Package files - i.e. Zip files adhering to a specific schema re having a manifest etc.

[Via @maartenba]: There's a Mono impl of System.IO.Packaging [which is nice as the solution needs to work cross-platform].

0

There are 0 best solutions below