NuGet.org has very good documentation and was a good source of knowledge for learning about creating NuGet packages.  Consult the documentation first if you have questions.

Package Configuration

There are a few build properties in the /lang/cs/build.props file that determine how the NuGet packages are created.  IsSnapshot determines if the packages created are pre-release packages.  If IsSnapshot is set to true, the NuGet package will contain the ID -SNAPSHOT- followed by the build property value SnapshotNumber.  If IsSnapshot is set to false, the package will be considered a release package.

Package Version

The package version is pulled from the /lang/cs/pom.xml file; specifically the value under <project> -> <parent> -> <version>.  The version id is extracted from this string by removing the trailing -SNAPSHOT from the version string. This value is then used as the NuGet package version.

The Nuspec files in each project's directory contains $version$ tokens.  The first is for the package itself; each package has a version.  The remaining $version$ tokens specify the version of each of the packages dependencies. We want to replace the $version$ token for the package as well as the  dependent REEF projects with our version from the pom.xml file.  This should be done by passing -Version [versionNumber] to the 'Nuget.exe pack' command.  However, it only replaces the $version$ token for the package version, not for the package dependencies.  This means we have to manually edit the Nuspec files to correctly replace the $version$ token for the project's REEF dependencies.

The build accomplishes this by copying over each Nuspec file into a directory under /lang/cs/.nuget/nuspec.  Then the version string is extracted from the pom.xml file. Finally, the nuspec files under /lang/cs/.nuget/nuspec are updated to replace the $version$ token with the actual package version.  These finalized Nuspec files are then used for creating NuGet packages.

Creating Packages

You can automatically create nuget packages by executing build with Release Configuration.  This can be done in Visual Studio by going to File -> Build -> Configuration Manager and then selecting Release under Active solution configuration. You can also do this from msbuild by typing 'msbuild /p:Configuration=Release'.

Packages will be created under /lang/cs/.nuget/packages.

Pushing Packages to NuGet.org

To push a package to NuGet.org, first you have to be an owner for each NuGet package. Email one of the current owners to request permission to be a package owner.  Next, the environment variable NuGetApiKey must be set to the value of your NuGet.org API key. Finally, you have to set the PushPackages property in build.props to true.

To change the repository location that packages are pushed to, update the NuGetRepository value in build.props.

 

  • No labels