Creating a NuGet package source

Publishing NuGet packages to the official package source is not always optimal or feasible, specifically when working with large packages (e.g. containing databases) and/or proprietary code solely intended for use within your company. Examples are based on Visual Studio 2010 and NuGet 1.7.

Reason

Creating a local package source (or “package repository” if you will) is an easy way to manage and share code not intended for public use, while benefiting from NuGet’s inherent version and dependency management.

Code

Creating a package source can be done in several ways:

  1. Place packages in a local folder
  2. Place packages in a network folder
  3. Host packages in a web server

Since most companies have shared network drives in place option 2 is very viable and extremely simple to setup, as shown in the following.

Example

  1. Install the NuGet Visual Studio extension
  2. Open the NuGet settings (Tools → Library Package Manager → Package Manager Settings).
    Opening the Library Package Manager
  3. Add a new package source by entering a name (e.g. “Company proprietary packages”) and choosing whatever location the packages are at.
    Adding a NuGet package source

That’s it! The new package source is now available in the “Manage NuGet Packages” dialog:

Open "Manage NuGet Packages" dialog

Using the new package source

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s