Come creare un pacchetto di boschetto a mano (senza Nuget.exe o Nuget Explorer)?

StackOverflow https://stackoverflow.com//questions/9642183

  •  10-12-2019
  •  | 
  •  

Domanda

Ho cercato descrizioni dei file che entrano in un pacchetto Nuget (.nupkg), ma devo ancora trovare una guida definitiva, la maggior parte di tutto ciò che si assume che devi usare Nuget Explorer, o il Nuget.exe - Ma bene, diciamo solo che sono ostinato.

Utilizzo dell'esplora Nuget per creare un pacchetto Produce una directory con file che vorrei creare utilizzando uno script o qualche altro strumento (oltre a Nuget.exe). Quindi, dato questo semplice layout di directory generato da Nuget Explorer, sto cercando la definizione del file .psmdcp, il file .rels, il file [content_types.xml], e ovviamente il file ProjectX.NUSUC.

Posso trovare alcuni dettagli o dedurli, per [content_typex.xml] e il file .nuspec. Ho provato a fare un pacchetto con solo la lib / dir, è contenuto e un file di nospec, ma a quanto pare non è sufficiente, e ottengo Package does not contain a manifest - che sospetto significano che il .nuec da solo non è il pieno manifesto.

lib/
  ProjectX.dll
  ProjectX.pdb
package/
  package/services/metadata/core-properties/____hash____.psmdcp
_rel/
  .rels
[Content_Types.xml]
ProjectX.nuspec
.

Non c'è una guida per fare un .nupkg a mano? È davvero così complicato un processo?

È stato utile?

Soluzione

I've written a blog post about how you could use the NuGet XSD: http://www.xavierdecoster.com/post/2012/03/08/Hidden-gem-the-NuGet-package-manifest-XSD.aspx

Also, take a look at the NuGet package conventions in the docs: http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package#Package_Conventions

If you need more detailed hands-on, there's also a Pro NuGet book that goes in-depth into various scenarios: http://www.amazon.com/NuGet-Professional-Apress-Maarten-Balliauw/dp/1430241918

Altri suggerimenti

.nuspec defines properties about your package (the metadata) as well as a list of files to include in the package. There are plenty of descriptions of this around, so the bits that needs to be addressed are the files that are added by the tools:

.nupkg files follow the Open Packaging Convention. As you have figured out, it is really a .zip file with some predefined files. The _rels directory contain relationships between "parts". Think of a Word document containing images and Excel spreadsheet tables to get an intuition of "parts".

Packages mostly contain only one part; the package itself (but can probably contain sub-packages for modules). The _rels/.rels file defines the relationship for the main, top-level package. A relationship has an ID, a url that describes the kind of relationship and a target, which is the file which has this relationship to the package. Most packages has a relationship to the .nuspec file, which is of kind "manifest", and to the .psmdcp file, which is of kind "core-properties". The IDs of these relationships only need to be unique within the package, so they could be simply strings such as "R1", "R2", but for some reason they are "R" + 16 first bytes of GUID, in choco.

The core-properties seems to be mostly a rehash of the manifest file, dressed in Dublin Core tags instead of the nuspec; I guess in theory other programs could present the package based on these (if you embed it in a Word-document!). Probably psmdcp is an abbreviation of "Package Services Metadata Dublin Core Properties". Checking NuGet.Core/NuGet.Packaging/PackageCreation/Authoring/PackageBuilder.cs we see that the name of the file is a simply a GUID with "N" format (just digits). The lastModifiedBy property is the version information of the "choco" assembly itself; I guess you can really put anything there if you create the files yourself.

[Content Types.xml] defines the file format of extensions, in the form of MIME types. This is mostly boiler-plate.

So, in conclusion: Based on the .nuspec you can generate all the other missing files and put together the .nupkg yourself, even in a Powershell script.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top