Creating a NuGet Package

Elements allows you to create a NuGet Package from your project, to deploy a class library for use by other members of your team or the general public.

To have your project build to a NuGet Package (a zip file with the .nupkg extension), simple enable the "Create NuGet Package" option in Project Settings.

The Create NuGet Package option is only available on project level (not per individual Target), and that is because the a package is always built from the entire project and combines all (potential) Targets into one.

In order to qualify for a NuGet package, the project must be

  • Single-target (the norm) or Multi-target.
  • Every target must be a .NET (Echoes) project (for now).
  • Every target must have have an OutputType of "Library".

If these criteria are not met, the project build will fail with an error.

Configuring The NuGet Package

Once the Create NuGet Package option is set to True/YES, additional settings can be used to configure your package:

  • PackageName – the name (and "ID") of your package. Defaults to the AssemblyName/BinaryName
  • PackageVersion – the version of your package. Defaults to the AssemblyVersion, if set.
  • PackageAuthors – a human-readable string that describes the author(s) of the package
  • PackageTags – a list of tags to heklp users find your package
  • PackageProjectUrl – URL to a public website that describes the package or the product/project it is part of.
  • PackageIconUrl – URL tom a public icon image for your package.
  • PackageLicenseUrl – URL to a public web page that shows the license for yur package.
  • PackageDescription – a human-readable description of your package.
  • PackageReadMe – a Markdown (.md) file that is aprt fo your project and provides a mlore detailed description of the package.

Note that all the produced URLs are merely informational, and will be included as part of the packages metadata. They will not be downloaded/accessed during build. All values are optional, but you will want to make sure you set a valid PackageVersion.

If no PackageVersion or AssemblyVersion is set, EBuild will obtain the assembly version from the main deliverable of the first target – assuming that a version has been set by other means, such as the [AssenblyVersion] attribute, or otherwise fall back to 0.0.0

Multi-Target Packages

As mentioned above, a multi-target project can be built into a single NuGet package, providing a unified distribution of a library for different .NET Target Frameworks (such as Classic, .NET Core, or .NET Standard).

For this to work, each target must have a unique target platform name and/or version. For example, yu might have three targets, with TargetFramework set to .NET 4.8, .NETCore 7.0 and .NET Standard 2.1 (for instance).

You could also have targets for different versions of the same TargetFramework, for example .NET Core 3.0, .NET Core 5.0 and .NET Core 7.0.

During build, EBuild will compile each target individually, as it always does. When it comes to packaging, it will then combine the output of all Targets into the single package, with the .nuspec XML file containing metadata (such as dependencies) for all targets, and each targets built output going into a unique folder within the package structure, named after its TargetFramework.