In-Depth

6 Top .NET Package- and Dependency-Management Tools

They may not be sexy, but package managers are an integral part of every developer's work -- using the right ones can make you more productive. Read on to find out what -- and where -- they are.

It's not a new problem with computing: How you do find software and get it installed correctly on your system? For executables, we can download them from the Web, and app stores such as the Windows Store have simplified this process quite a bit.

For the app developer or system admin, however, the process of getting utilities, libraries and frameworks installed, along with any required dependencies -- particularly when dealing with the huge ecosystem of open source software -- represents a bigger problem. And this is where package management comes to the rescue.

Package managers help you download, install, configure and update software "packages" from repositories. A package contains the software itself (possibly as source), plus metadata specifying the locations of any dependencies that need to be installed and instructions for automatic compilation, when necessary.

A canonical example (excuse the pun) is the collection of apt-get utilities on Linux (specifically Debian/Ubuntu distros). On a bare-metal Ubuntu server, for example, you'd use apt-get to install anything you need to run the server, from programming languages, interpreters and compilers (PHP, for instance) to Web servers (Apache, Nginx) and more:

sudo apt-get install mysql-server mysql-client

Apt-get checks its repositories, downloads the package, grabs any dependencies specified by the package, unpacks the files and installs them. If the package requires compiling, apt-get can call make as part of the installation process. All in all, it's a pretty slick tool to have at your disposal.

There are apt-get options to specify the package location, update to the latest version, attempt to fix broken installs and remove packages along with their dependencies -- taking into account whether any other packages are relying on those dependencies. Tecmint has a rundown of 25 useful apt-get and apt-cache command examples if you want to learn more.

RPM is the equivalent package manager for Red Hat Linux and its relatives. Mac OS users might be familiar with Fink, Homebrew and MacPorts. A more recent addition, focused on Objective-C programming, is CocoaPods.

These sound like handy tools, right? But where's the love for you guys working on Windows and the.NET Framework?

You haven't been left out. Here are some great package- and dependency-management tools created specifically for Windows-based development.

NuGet
NuGet is probably the best-known package and dependency manager for, in Redmond's words, "the Microsoft development platform including .NET." As with the other tools I've mentioned here, NuGet helps you find, install, update and remove packages. However, similar to CocoaPods, NuGet focuses primarily on package and dependency management at the development-project level.

While NuGet is technically an open source project, development has been supported directly by Microsoft, and NuGet has been included as a default tool in Visual Studio 2012 and Visual Studio 2013, as well as WebMatrix 3. A NuGet Package Manager extension is available for Visual Studio 2010 and Visual Web Developer 2010 Express.

The NuGet Gallery lists all available packages for download. You can also search this package listing directly from the NuGet extension within Visual Studio or via the command-line utility.

The process for adding a NuGet package to a Visual Studio project is similar to adding any other kind of reference. Go to Solution Explorer, right-click on the References folder, then click Manage NuGet Packages. The package manager dialog box is shown in Figure 1.

[Click on image for larger view.] Figure 1. Managing NuGet Packages in Visual Studio

In the left column, select Online to browse or search packages available in online repositories. Figure 2 shows the WebGrease package has been selected from the NuGet Gallery. Note that the green checkmark indicates this package is already installed on my system. The right column shows version and other information for the package. Note in particular the dependencies: Antlr and Newtonsoft.Json.

[Click on image for larger view.] Figure 2. Packages in the NuGet Gallery, Showing Dependencies

If the package isn't already installed, click it to highlight the package, then click the Install button. It's really that easy.

There's also a command-line utility, nuget.exe, if you roll old-school. David Ebbo wrote a brief tutorial on Installing NuGet packages directly from the command line and a full, current Command-Line Reference is posted in the NuGet documentation.

For further information directly from developers using NuGet, start out with Scott Hanselman's blog post, "Introducing NuGet Package Management for .NET - Another Piece of the Web Stack," and Alex Papadimoulis' blog post, Taking NuGet to the Enterprise," which looks at NuGet at a slightly higher team-development level.

By the way, the NuGet Docs are excellent and should be your first resource for learning how to use this tool. Hats off to the NuGet community for putting this together.

Creating NuGet Packages
Of course, package managers aren't much use unless developers contribute handy libraries and frameworks to the repositories. It's a simple process: Take care to follow the Package Conventions. There's even a GUI utility to help you along.

Not surprising, Scott Hanselman has a thorough post, "Creating a NuGet Package in 7 Easy Steps - Plus Using NuGet to Integrate ASP.NET MVC 3 into Existing Web Forms Applications."

Open Wrap
OpenWrap is another popular open source package-management sytem for .NET programmers. Created by Sebastien Lambla, OpenWrap is command-line only and supports both OpenWrap and NuGet packages. OpenWrap also includes ReSharper integration, so ReSharper knows about the packages you've installed and doesn't throw up spurious warnings.

Finding packages is simple:

    o list-wrap -remote openwrap
    o list-wrap -remote nuget

To actually "wrap" a package in your project, it's as simple as:

    o add-wrap nhibernate.core

To create a package, check the Building packages from the OpenWrap wiki as well as Sebastien's post, "Creating a New Project with OpenWrap."

As far as whether you should use NuGet or OpenWrap, the decision really comes down to your workflow preferences. There's a good Stack Overflow question on OpenWrap vs NuGet with a bullet-point breakdown of features, answered by the developers themselves.

NPanday
NPanday is an Apache Incubator project "to integrate Apache Maven into .NET development environments." Maven is more of a build-automation and dependency-management tool, and also developed more specifically for Java-based development, but developers have figured out how to Maven build for .NET applications.

The good news is that you can integrate NPanday as a Visual Studio extension for Visual Studio versions 2005, 2008 and 2010.

The bad news is development appears to have stalled since the last release in 2011.

If you're a fan of Maven, however, and already knee-deep in Java development, this might be an option worth looking into.

Chocolatey NuGet
So, those are the big, established players in package management on Windows. But they're not the only options.

Chocolatey is a general-purpose "tools enabler" and "silent application installer" for Windows, modeled after apt-get.

Chocolatey is built on Windows Powershell 2.0 and uses the NuGet packaging infrastructure. Where NuGet is focused on installing and managing code within your development environment, Chocolatey expands those capabilities to installing software in general -- including installing and configuring the software development environment itself.

The Windows Powershell infrastructure gives you a great deal of flexibility in the kind of setup and configuration you can accomplish with Chocolatey. You can install binary packages (both installable and portable executables), Windows Powershell command packages (.powershell scripts), development packages (similar to NuGet) and "meta" packages (collections of dependencies).

"Virtual" packages, which specify dependencies based on capability, are currently under development. For example, if you wanted a PDF reader, the virtual package could check whether any PDF-capable reader from a specified list is already installed and, if none is found, let you choose which to install.

Because it's based on NuGet, you can create your own packages and push them out to repositories; but check the docs, because Chocolatey supports capabilities beyond NuGet. For example, Rob Reynolds' post, "Guidance on Packaging Apps with Both an Install and Executable/Zip Option," discusses package creation.

Chewie
Chewie is yet another NuGet offshoot that attempts to incorporate some features of the Ruby Bundler gem manager into the package\-management workflow on Windows.

This is kind of meta, because Chewie uses NuGet and Chocolatey and Windows PowerShell 3.0 to do its magic. (Chocolate nougat is chewey? Han shot first? Maybe better not to ask ...)

To learn more about Chewie, I'll direct you to Ian Davis' Visual Studio Magazine article from last year, "Clean Up NuGet Dependencies With Chewie."

Ninite
OK, Ninite isn't really a package manager in any typical sense of the word, and unlike the rest of the apps I've discussed, it's neither open source itself nor open source focused. But it is a handy utility and it does fall into the same general category as apt-get and Chocolatey.

Basically, Ninite lets you select from 90 or so free Windows or Linux applications and runtimes on its Web site, as shown in Figure 3. It then creates a single download and installer for the applications you selected.

[Click on image for larger view.] Figure 3. Ninite Lets You Choose Which Apps to Install

The benefits of this service include always getting the latest version of the apps, generating a one-stop, repeatable installer for all of the apps, and having Ninite take care of the entire installation process. As a bonus (or the whole point, depending on your point of view), the Ninite installer makes sure you don't get toolbars, malware or other junk sometimes added by freeware download sites.

The downside is you can't provide your own packages for the Ninite service.

The basic Ninite installer service is free. For more features there are paid Pro and Updater services.

What's Next
I work on a lot of different systems, and I've long been a fan of the painless configuration enabled by apt-get, Homebrew, the Ruby gem installer and similar tools.

It's great to see developers bringing these kinds of package-management tools to Windows and .NET Framework development. We're not all the way there yet, though. Ian Davis made some great comments in his 2012 post, "NuGet: You're Doing It Wrong." Food for thought as you keep moving forward and making your development tools better.

comments powered by Disqus
Most   Popular
Upcoming Events

.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.