While NuGet provides all the power needed to explicitly control every aspect of a package (something the exacting control freak in me really appreciates), a simple project like this doesn’t need anything more than the standard conventions.
In a piece of recursion fit for a Christopher Nolan film, the easiest way to install the NuGet command line tooling so that we have it available to use from our build script is to use NuGet itself - from inside Visual Studio.
Now we can work out how to do it by hand, our usual prelude to automation. With a bit of work (details below), we end up with this command:
(The options are wrapped for readability; if you’re trying this out for yourself, they all need to be on the same line.)
In order for this to work, I needed to review of the
packages.config file to ensure that the dependencies were nice and tidy. I removed some dependencies not currently required, and flagged a few that are only needed during development so they’re not forced upon library consumers.
If you look at the full
packages.config file from the repo, you’ll see a large number of static code analysis packages, tools that I’m trying out to see how well they work. None of these are required to run the CommandLineProcessor itself, so I’ve marked all of them as
Not everything associated with a NuGet package can be derived by convention, so we need a nuspec file with some key details listed:
ReadMe.txt file that’s included will be automatically opened, by Visual Studio, when the package is installed as a quick reference reminder of the conventions used by the project.
We can now write the usual psake task to locate
nuget.exe for us:
As before, we’re using a wildcard (
*) for the version number so that we will always find it, regardless of the exact version available.
Next, a simple task to build the actual package:
Most of this task is stuff we’ve seen before.
We use the
$semver10 version reference because these packages are going to be shared via NuGet.org; if we were using our own internal server, we’d use the semver 2.0 variable instead.