手でNUGETパッケージを作成する方法(NUGET.EXEまたはNUGET Explorerなしで)?

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

  •  10-12-2019
  •  | 
  •  

質問

NUGETパッケージ(.nupkg)に入るファイルの説明を検討しましたが、私はまだ決定的なガイドを見つけていません、ほとんどのすべてがNUGET Explorerを使用しなければならない、またはnuget.exe - しかし、まあ、私が頑固なことを言ってみましょう。

NUGETエクスプローラを使用してパッケージを作成すると、スクリプトやその他のツール(Nuget.exeの他に)を使用して作成したいファイルを含むディレクトリが生成されます。したがって、Nuget Explorerによって生成されたこの単純なディレクトリレイアウトを考えると、.psmdcpファイル、.relsファイル、[content_types.xml]ファイル、およびもちろんProjectX.Nuspecファイルの定義を探しています。

[content_typex.xml]と.nuspecファイルの詳細を見つけることも、それらを推測することもできます。私はちょうどlib / dir、content、そしてnuspecファイルを使ってパッケージを作ってみましたが、それは十分ではありません、そして私はPackage does not contain a manifestを手に入れました - 私が疑わしいのは.Nuspecだけが全開ではないことを意味します。

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

。inupkgを手で作るためのガイドはありませんか?それは本当にプロセスを複雑にしていますか?

役に立ちましたか?

解決

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

他のヒント

.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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top