Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: API to re-list a previously unlisted package #5191

Closed
chrisdunelm opened this issue Dec 14, 2017 · 14 comments
Closed

Feature request: API to re-list a previously unlisted package #5191

chrisdunelm opened this issue Dec 14, 2017 · 14 comments

Comments

@chrisdunelm
Copy link

It's currently possible to unlist a package from nuget.org using the API, as documented here.

However, there doesn't appear to be an API to re-list a previously unlisted package.
Please can one be added?

We manage hundreds of nuget packages on nuget.org, and occasionally it's very useful to be able to programmatically unlist/relist many packages. For example, when sorting out problems caused by #5183

Thank you

@scottbommarito
Copy link
Contributor

Fortunately, it's already possible, but apparently not documented.

If you hit the same url as the unlist API (https://www.nuget.org/api/v2/package/{ID}/{VERSION}) with a POST instead of a DELETE, it will re-list the package.
(https://github.com/NuGet/NuGetGallery/blob/master/src/NuGetGallery/Controllers/ApiController.cs#L590)

The same functionality exists in nuget.exe. I believe the command is "publish" and the rest of the command is the same as the unlist command ("delete").

Leaving this open because we need documentation on this. @karann-msft @anangaur

@karann-msft
Copy link
Contributor

karann-msft commented Dec 14, 2017

here's what happens when you try running the publish command

C:\Users\karann>nuget publish PrintHelloNuget 1.4.8 -source nuget.org -apikey <redacted>
Unknown command: 'publish'
NuGet.CommandLine.CommandLineException: Unknown command: 'publish'
   at NuGet.CommandLine.CommandManager.GetCommand(String commandName)
   at NuGet.CommandLine.CommandLineParser.ParseCommandLine(IEnumerable`1 commandLineArgs)
   at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)

Not a documentation issue.

Moreover, no such command shows up in nuget help

@scottbommarito
Copy link
Contributor

Maybe it isn't in nuget.exe--I was pretty sure it was. In any case we are still missing the documentation for the nuget.org API.

@karann-msft
Copy link
Contributor

karann-msft commented Dec 14, 2017

Please create a docs issue and provide sufficient information on what needs to go into the doc. Better yet, create a PR to the docs repo :)

tagging @joelverhagen who authored this doc to understand why did we omit publish.

@chrisdunelm
Copy link
Author

Thanks for the instant documentation :)
I'll try POSTing to the unlist URL tomorrow.

@joelverhagen
Copy link
Member

It is undocumented because it is not part of the official protocol, meaning the official NuGet client does not use it. Also, it is unclear whether other server implementations support it (I haven't tried). As @scottbommarito mentioned, the POST /api/v2/package/{ID}/{VERSION} endpoint is implemented on NuGet.org but again this is not officially supported endpoint (e.g. push or unlist are "officially supported").

@chrisdunelm, feel free to use the endpoint right now (via a custom script). It is unlikely that we will remove or change this endpoint because a) our end-to-end tests use it to test the unlist/relist flow and b) other people are using it. If changes do sometime occur to any publicly accessibly endpoint, we will announce it via the NuGet/Announcements repository.

Also, I would recommend creating an issue on NuGet/Home if you are interested in getting official support for this feature into the NuGet client.

I would be happy to document it after talking to the team and agreeing this is something we want to officially support. Thoughts, @skofman1 @xavierdecoster?

@anangaur
Copy link
Member

Typically we have not seen authors re-listing many packages together but seems like a general scenario for enterprises including Microsoft/.NET teams
@chrisdunelm Do you unlist all packages by default upon uploading and on a given day (coinciding with some release) re-list all packages to make them available?

I think it makes sense to have a nuget.exe command to re-list package.

@chrisdunelm
Copy link
Author

The POST worked fine. Thanks for suggesting it.
I would ask that, if possible, this is made part of the official protocol. I agree it's not a common requirement, but there will be occasions where it's very useful.

@anangaur No, we just nuget push and allow packages to become live as nuget.org indexes them. Our release times haven't been critical enough to need to be any more precise than this. Pushing all packages generally takes about an hour.
We do have some inter-package dependencies, but up until now the packages have become live on nuget.org fast enough that we've never seen a problem.

However, due to the problem that caused #5183, we had many packages that were live on nuget.org, but a common dependency was not live. So yesterday I programmatically unlisted all of the latest version of all packages; then today programmatically relisted them all. Being able to do this using the POST request was extremely useful.

(We also have had a number of occasions where we've released many packages containing a bug; and needed to unlist them all. This isn't relevant for the relist discussion though as these bug-ridden packages never need re-listing)

@skofman1
Copy link
Contributor

@joelverhagen , agree we should document this endpoint.
Created an issue for client to track the suggestion to add a "publish" command: NuGet/Home#6329

@skofman1
Copy link
Contributor

skofman1 commented Jan 5, 2018

Documentation was updated. Closing.

@skofman1 skofman1 closed this as completed Jan 5, 2018
@joelverhagen joelverhagen reopened this Jan 5, 2018
@joelverhagen
Copy link
Member

Waiting for deployment.

@skofman1 skofman1 added this to the S128-129 - 2017.12.4 milestone Jan 5, 2018
@chrisdunelm
Copy link
Author

@maartenba
Copy link
Contributor

Thanks for getting the docs out! (Note the docs say a 204 is returned, but code returns an EmptyResult() which writes a regular 200)

(and even though it was apparently already in the code base would have been nice to get a heads up on this in the announcements repo)

@joelverhagen
Copy link
Member

@maartenba, great feedback, thanks.

Concerning the 204 vs. 200 -- nice catch. I made a bad assumption about EmptyResult. I'll fix that.

Concerning the announcement -- yeah, good idea. @anangaur, could we make an announcement about this? This endpoint has been around for ages but we just now made it visible by documenting it in the API docs. We can work on the wordcraft tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants