Introducing a NuGet.exe extension for Package Source Discovery

3 minute read

As we have reached 1500 NuGet feeds on MyGet for the first time – with some great stuff in our Gallery - we felt it's about time we make it even easier for people to discover them. Where NuGet makes it easy to discover packages, we want to push it further and make it easier to discover package sources as well. We've had numerous discussions with several people closely involved with the NuGet project and are quite happy with the outcome of our combined efforts: the NuGet Package Source Discovery (PSD) spec. Thanks again Scott, Phil, Jeff and Howard for your most valuable input and feedback! Be sure to check the announcement on Maarten's blog!

The Spec

Before you think here we go again with yet another spec, let us explain the following first: we are recycling an existing spec (RSD – Really Simple Discoverability) and reuse existing standards (Dublin Core). We simply combined them into something suitable for package source discovery. This spec has a single goal in mind: make it as easy as possible to discover package sources (and its metadata).

The spec is flexible enough to support very basic as well as more complete implementations:

  • Most basic scenario: define a relationship between your own domain/web site and a NuGet package source by directly pointing to it
  • Most intelligent scenario: define a relationship between your own domain/web site and a NuGet package source by exposing a discovery endpoint

Obviously you can combine the above, or have multiple relationships defined in a single HTML page. We started with a simple NuGet package that adds a new PowerShell cmdlet Discover-PackageSources to your NuGet Package Manager console. We also implemented a nuget.exe commandline extension: the NuGet.PackageSourceDiscovery.Extension. Again, all sources are available on our GitHub repository. Also check the project Wiki for further details.

The NuGet CLI Extension

Important note: this extension requires NuGet.exe v2.3+ (so grab it from or wait for the release).

I usually ship stuff as a NuGet package, however, for this one, I figured it was more appropriate to give you a PowerShell one-liner. Open a CMD prompt and run the following script:

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString(''))"

No need to be afraid, the URL this script is pointing to is just a Gist containing some more PowerShell.

Once you've installed the extension, it will be available whenever you run nuget.exe on your machine. You can easily verify this by running nuget help. Notice the new discover command?

Now, let's see how you can use it: nuget help discover.

Straightforward, isn't it? Let's put it to a test. You probably have guessed by now that my blog now also functions as a NuGet Package Source Discovery endpoint. But first, I want to see the configured NuGet endpoints on my machine: nuget sources.

Here goes: nuget discover –Url

The feeds that were discovered are now added to your %appdata%\NuGet\NuGet.config.

Obviously, we drafted support for this spec into MyGet as well: read all about it on our blog!

What happened under the hood? Check the sources of my blog: you'll find the following tag:

<link rel="nuget" type="application/rsd+xml" src=""/>

That URL is a simple 301 to a gist containing my RSD file. I don't even need to redeploy anything to maintain my discovery endpoint: I update the gist and redirect to the new raw gist. Done!

What's next?

Imagine a world where you could point the NuGet Package Explorer to your corporate web site and have it automagically discover the feeds you can use? Or have them added to your NuGet settings in Visual Studio all at once? And when authenticated, it could even discover your API keys and symbol server settings! It's up to you how far you want to take this.

One could build a feed monitoring dashboard on top of it, or give me a widget I can plug into my web site, or … well, you get it, use your imagination J

We really believe this type of functionality can add value to the NuGet ecosystem, and we'd love to see support for it in all NuGet clients. Send us your feedback, ideas, remarks and concerns. Raise your voice on Twitter, our blog and our GitHub repository. Open an issue, start a discussion, submit a pull request, or even better: let us know about your implementations!

Leave a Comment