NuGet 1.6 Gallery Service Endpoints

In NuGet 1.6 we're simplifying the endpoints that users have to manage. To push a package, you only need the root URL (the URL without a path element), but you have the option to provide the full URL to the endpoint which is used unchanged.

Rationale

In the past, there was no way to be fully explicit about the service endpoint. NuGet.exe would append paths to the URL that were specific to nuget.org. This means new versions of the gallery that may want to change the URL end up being broken on older clients with no workaround.

In NuGet 1.6, we have a hybrid model. If you specify a root URL with no path segment, NuGet will append the necessary portions. If the URL has a path segment, it will respect the path segment as-is. It will not append the crud it used to.

This does mean using NuGet.exe 1.6 to post to a NuGet 1.5 server will break unless you explicitly specify the full source.

Scenarios

Specifying the root URL only

As mentioned earlier, NuGet.exe 1.6 appends the correct path to a root URL.

    nuget push Foo.nupkg -Source http://nuget.org/

NuGet.exe knows its version and appends: /api/v2/package

Thus this sends an HTTP POST request to http://nuget.org/api/v2/package with the package contents in the request body. Note that the API Key is sent as part of the request headers using the key X-NuGet-ApiKey.

Specifying the fully qualified URL to the service

NuGet 1.6.exe will support being explicit about the URL endpoint. It will not append anything to these URLs.

    nuget push Foo.nupkg -Source http://example.org/custom/

NuGet.exe sees a path element on the URL and uses the URL as-is.

Thus this sends an HTTP POST request to http://example.org/custom/ with the package contents in the request body.

Workaround for NuGet 1.5 galleries w/ NuGet 1.6 exe

To post to a different version of NuGet.org (or a different implementation such as myget), specify the full URL.

    nuget push Foo.nupkg -Source http://nuget.org/PackageFiles/ApiKey

Download Package

To download a package, make a GET request to: http://nuget.org/api/v2/package/{id}/{version}

NuGet Delete

Note that as of NuGet 1.6, hard deletes are no longer supported. Instead, a delete will cause a package to no longer be listed in search results or when browsing, but the package can still be installed as a dependency to another package.

    nuget delete mypackage 1.0.0 -Source http://nuget.org/

Sends an HTTP DELETE request to: http://nuget.org/api/v2/package/{id}/{version} which in this case is http://nuget.org/api/v2/package/mypackage/1.0.0.

Whereas

    nuget delete mypackage 1.0.0 -Source http://example.org/custom/

Sends an HTTP DELETE request to: http://example.org/custom/package/{id}/{version}.

Open question: Do we append the package portion?

Last edited Nov 16, 2011 at 8:21 PM by Haacked, version 10