Hosting Your Own Local and Remote NuGet Feeds

nuget, code, open source 0 comments suggest edit

Note: Everything I write here is based on a very early pre-release version of NuGet (formerly known as NuPack) and is subject to change.

A few weeks ago I wrote a blog post introducing the first preview, CTP 1, of NuGet Package Manager. It’s an open source (we welcome contributions!) developer focused package manager meant to make it easy to discover and make use of third party dependencies as well as keep them up to date.

As of CTP 2 NuGet by default points to an ODATA service temporarily located at http://go.microsoft.com/fwlink/?LinkID=204820 (in CTP 1 this was an ATOM feed located at http://go.microsoft.com/fwlink/?LinkID=199193).

This feed was set up so that people could try out NuGet, but it’s only temporary. We’ll have a more permanent gallery set up as we get closer to RTM.

If you want to get your package in the temporary feed, follow the instructions at a companion project, NuPackPackages on CodePlex.com.

Local Feeds

Some companies keep very tight control over which third party libraries their developers may use. They may not want their developers to point NuGet to arbitrary code over the internet. Or, they may have a set of proprietary libraries they want to make available for developers via NuGet.

NuGet supports these scenarios with a combination of two features:

  1. NuGet can point to any number of different feeds. You don’t have to point it to just our feed.
  2. NuGet can point to a local folder (or network share) that contains a set of packages.

For example, suppose I have a folder on my desktop named packages and drop in a couple of packages that I created like so:

packages-folder

I can add that director to the NuGet settings. To get to the settings, go to the Visual Studio Tools| Options dialog and scroll down to Package Manager.

A shortcut to get there is to go to the Add Package Dialog and click on the Settings button or click the button in the Package Manager Console next to the list of package sources. This brings up the Options dialog (click to see larger image).

Package Manager
Options

Type in the path to your packages folder and then click the Addbutton. Your local directory is now added as another package feed source.

Options-with-local-source-added

When you go back to the Package Manager Console, you can choose this new local package source and list the packages in that source.

MvcApplication7 - Microsoft Visual Studio (Administrator)
(2)

You can also install packages from your local directory. If you’re creating packages, this is a great way to test them out without having to publish them online anywhere.MvcApplication7 - Microsoft Visual
Studio (Administrator)
(4)

Note that if you launch the Add Package Reference Dialog, you won’t see the local package feed unless you’ve made it the default package source. This limitation is only temporary as we’re changing the dialog to allow you to select the package source.

Options-setting-default

Now when you launch the Add Package Reference Dialog, you’ll see your local packages.

add-package-reference-local-packages

Please note, as of CTP 1, if one of these local packages has a dependency on a package in another registered feed, it won’t work. However, we are tracking this issue and plan to implement this feature in the next release.

Custom Read Only Feeds

Let’s suppose that what you really want to do is host a feed at an URL rather than a package folder. Perhaps you are known for your great taste in music and package selection and you want to host your own curated NuGet feed of the packages you think are great.

Well you can do that with NuGet. For step by step instructions, check out this follow-up blog post, Hosting a Simple “Read Only” NuGet Package Feed.

We imagine that the primary usage of NuGet will be to point it to our main online feed. But the flexibility of NuGet to allow for private local feeds as well as curated feeds should appeal to many.

Tags: NuGet, Package Manager, OData

Found a typo or error? Suggest an edit! If accepted, your contribution is listed automatically here.

Comments

avatar

8 responses

  1. Avatar for Bret Ferrier
    Bret Ferrier October 21st, 2010

    I have really been liking the use of NuPack and have found it to be one of those things that I wonder what I did before I had it. I really like how you can add JavaScript and non DLL files to projects as I use a number of jQuery libraries when creating any useful web project.

  2. Avatar for Garry Shutler
    Garry Shutler October 21st, 2010

    How do you add another source without Visual Studio? Say if you wanted to pull local packages on a build server without having to install VS and configure it for each project?

  3. Avatar for Bullgod
    Bullgod October 25th, 2010

    I have 2 questions:
    1. How does NuPack handle transitive dependencies? I.e, I have a.dll that depends on a b.all which in turn has infragistics references. Let's assume I create a package for project a, that produces a.dll, so it will have b.all as a reference. Now, will Nupack resolve the transitive infragistics dependency from b.dll ? will it include it as part of the package? Or do we have to manually add all transitive dependencies?
    I am sure handling transitive dependencies is a common problem and currently i am looking to address that. Does NuPack provide a better solution for this? Or will it copy down all transitive dependencies and build the package?
    2. If i create a package for 10 commonlibraries that are to be used and publish it. If a user wants to use a package, will he ahve to add all the 10 as reference. Can he choose to add the 1 or 2 he woudl like to use from the entire package? If so, hwo is this supported in Nupack

  4. Avatar for James Fleming
    James Fleming October 27th, 2010

    Boom!
    Testing the host-your-own-feed and getting
    list-package
    Exception calling "GetPackages" with "0" argument(s): "Unable to read feed. Verify that a feed is hosted at the remote server and is available."
    At C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\CodePlex Foundation\NuPack Tools\0.1\Scripts\nupack.ps1:257 char:35
    + return $repository.GetPackages <<<< () | Select-Object Id, Version, Description
    + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : DotNetMethodException

    The feed page reads as:
    <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
    - <service xml:base="http://localhost:1000/odata/v1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns="http://www.w3.org/2007/app">
    - <workspace>
    <atom:title>Default</atom:title>
    - <collection href="Packages">
    <atom:title>Packages</atom:title>
    </collection>
    </workspace>
    </service>

  5. Avatar for james Fleming
    james Fleming October 27th, 2010

    I discovered the route of my problem - was the latest changeset (and several before):
    c6ee0f12c63f by dfowler Today at 2:48 AM 12
    Associated with Release: NuPack 10-26-2010 build.
    Use GetResponse in GetResponseUri to remove code duplication.
    This one worked:0599a8e0692c by Haacked nupack.codeplex.com/.../HaackingNuPackServer

  6. Avatar for Bob
    Bob October 29th, 2010

    @James Did the route to your problem lead you to the root of your problem?

  7. Avatar for David
    David December 24th, 2010

    Nice post, very helpful. I saw another post by Steve Michelotti refering to how to download the packages to your local repository, I think that is a nice complement to this one.

  8. Avatar for Jon Galloway
    Jon Galloway February 25th, 2011

    David - The NuGet feed has changed since then, breaking Steve's script. I've posted an update to it here: weblogs.asp.net/...