Skip to content

Skip Duplicate switch added to nuget.exe push command #1630

Closed
NuGet/NuGet.Client
#2802

Description

@maartenba

From @lukemcgregor on October 22, 2015 21:42

Currently if the package is already published the following occurs

Pushing Pkg 1.0.0 to the NuGet gallery (https://www.nuget.org)...
Failed to process request. 'A package with id 'Pkg' and version '1.0.0' already exists > and cannot be modified.'.
The remote server returned an error: (409) Conflict..

And a non-zero return code is returned from nuget push

I would like to add another switch to pack so that the following occurs

nuget push Pkg -SkipIfAlreadyPublished

A package with id 'Pkg' and version '1.0.0' already exists, skipping...

A zero return code is returned.

This would allow for better integration with automated build tools which produce nuget packages.

Copied from original issue: NuGet/NuGetGallery#2743

Activity

  1. maartenba commented on Oct 23, 2015

    @maartenba
    ContributorAuthor

    From @lukemcgregor on October 22, 2015 21:54

    To do this I want to edit https://github.com/NuGet/NuGet.PackageManagement/blob/dev/src/NuGet.CommandLine/Commands/PushCommand.cs But I cant work out how to build the project.

    Ive tried using home (http://docs.nuget.org/Contribute/Setting-up-the-NuGet-Development-Environment) But the nuget3 solution doesn't appear to build the CLI.

    Building PackageManagement directly seems to fail as it refers to a bunch of nuget packages which dont exist yet.

  2. yishaigalatzer commented on Oct 23, 2015

    @yishaigalatzer

    @lukemcgregor the code lives in nuget.client.

    Before you send a pull request, we should have a discussion first, and agree on a design and approach.

    I have a few questions:

    1. Why are you pushing directly from your CI to nuget.org, this is a scenario we do not want to support. We can't force people to do it, but CI builds show go to public private feeds and not to nuget.org. nuget.org is intended for stable or stable pre-releases of a product and not for nightly/ci builds. There is not retention policy, or facilities to support that, nor we plan to add them.
    2. Why would your CI generate two builds of the same version, that seems like a pretty bad idea, unless of course you are trying to rebuild an RTM build (before publishing it to nuget).

    So I'm not so sure this is something we want to add as a top level support.

    Perhaps the right alternative is to support nuget.exe list -version {version} (today we only support -allversions) and then you can script your way happily with the result, but not encourage this behavior.

    Thoughts?

  3. added this to the milestone on Oct 23, 2015
  4. added
    Type:DCR
    and removed
    Type:DCR
    on Oct 23, 2015
  5. lukemcgregor commented on Oct 23, 2015

    @lukemcgregor

    My intent is not to publish every build that goes through CI, I totally
    agree thats the wrong way to do it, it creates a huge mess of versions and
    ruins everyones day. I think we are agreed here

    What I want to do is to remove some complexity around deploying to nuget.
    What I have found is that the decision to create a package is the same as
    the decision to create a new version. So when you increment a version
    number of a nuget package in code you are actually deciding to deploy that
    package. My aim is to automate the deploy bit when the version is
    incremented.

    I have written some stuff to query the nuget apis and precheck before
    running push but its a bit messy and it feels like it would be way tidier
    built into push as a skip over this package if no one has changed the
    version.
    On 24/10/2015 11:57 am, "Yishai Galatzer" [email protected] wrote:

    @lukemcgregor https://github.com/lukemcgregor the code lives in
    nuget.client.

    Before you send a pull request, we should have a discussion first, and
    agree on a design and approach.

    I have a few questions:

    1. Why are you pushing directly from your CI to nuget.org, this is a
      scenario we do not want to support. We can't force people to do it, but CI
      builds show go to public private feeds and not to nuget.org. nuget.org is
      intended for stable or stable pre-releases of a product and not for
      nightly/ci builds. There is not retention policy, or facilities to support
      that, nor we plan to add them.
    2. Why would your CI generate two builds of the same version, that seems
      like a pretty bad idea, unless of course you are trying to rebuild an RTM
      build (before publishing it to nuget).

    So I'm not so sure this is something we want to add as a top level
    support.

    Perhaps the right alternative is to support nuget.exe list -version
    {version} (today we only support -allversions) and then you can script your
    way happily with the result, but not encourage this behavior.

    Thoughts?

    —
    Reply to this email directly or view it on GitHub
    #1630 (comment).

  6. yishaigalatzer commented on Oct 24, 2015

    @yishaigalatzer

    What do you think about the list option? Then your script is as simple as

    List

    If errorlevel == 0 (package exists)
    {
    Skip
    }
    Else
    {
    Publish
    }

    BTW on our team we ALWAYS increment the version on every single build, makes it a lot easier to track issues even with dev builds.

    From: Luke McGregor [mailto:[email protected]]
    Sent: Friday, October 23, 2015 4:34 PM
    To: NuGet/Home [email protected]
    Cc: Yishai Galatzer [email protected]
    Subject: Re: [Home] Commandline switch on nuget push to skip if already published (#1630)

    My intent is not to publish every build that goes through CI, I totally
    agree thats the wrong way to do it, it creates a huge mess of versions and
    ruins everyones day. I think we are agreed here

    What I want to do is to remove some complexity around deploying to nuget.
    What I have found is that the decision to create a package is the same as
    the decision to create a new version. So when you increment a version
    number of a nuget package in code you are actually deciding to deploy that
    package. My aim is to automate the deploy bit when the version is
    incremented.

    I have written some stuff to query the nuget apis and precheck before
    running push but its a bit messy and it feels like it would be way tidier
    built into push as a skip over this package if no one has changed the
    version.
    On 24/10/2015 11:57 am, "Yishai Galatzer" <[email protected]mailto:[email protected]> wrote:

    @lukemcgregor https://github.com/lukemcgregor the code lives in
    nuget.client.

    Before you send a pull request, we should have a discussion first, and
    agree on a design and approach.

    I have a few questions:

    1. Why are you pushing directly from your CI to nuget.org, this is a
      scenario we do not want to support. We can't force people to do it, but CI
      builds show go to public private feeds and not to nuget.org. nuget.org is
      intended for stable or stable pre-releases of a product and not for
      nightly/ci builds. There is not retention policy, or facilities to support
      that, nor we plan to add them.
    2. Why would your CI generate two builds of the same version, that seems
      like a pretty bad idea, unless of course you are trying to rebuild an RTM
      build (before publishing it to nuget).

    So I'm not so sure this is something we want to add as a top level
    support.

    Perhaps the right alternative is to support nuget.exe list -version
    {version} (today we only support -allversions) and then you can script your
    way happily with the result, but not encourage this behavior.

    Thoughts?

    —
    Reply to this email directly or view it on GitHub
    #1630 (comment).

    —
    Reply to this email directly or view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fgithub.com%2fNuGet%2fHome%2fissues%2f1630%23issuecomment-150716813&data=01%7c01%7cyigalatz%40microsoft.com%7cccdb46fdb4b9481e4f1b08d2dc026269%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=I8%2bBO4AVjYt9ZuhyzJlooMYTsRSeoBbz7zdjjR8B%2bHQ%3d.

  7. lukemcgregor commented on Oct 27, 2015

    @lukemcgregor

    I have noticed that quite a few of the MS teams used to use build numbers in their nuget packages. This isn't strictly semver.

    I think if you do want to track explicit builds (which we don't care too much about) then you need to separate that from your semver completely.

    Perhaps a good method would be to use the AssemblyInformationalVersion or a specific nuget version to do the correct Semver version.

    eg:

    [assembly: AssemblyVersion("MAJOR.MINOR.PATCH.BUILD")]
    [assembly: AssemblyFileVersion("MAJOR.MINOR.PATCH.BUILD")]
    [assembly: AssemblyInformationalVersion("MAJOR.MINOR.PATCH")]
    

    This would let you look at the DLL deets to see the build but not propogate that to the actual package.

    Personally though the only relevant referable version for software I write is one with a distinct semver number.

  8. modified the milestones: , on Apr 19, 2016
  9. vijayganeshpk commented on Mar 23, 2017

    @vijayganeshpk

    +1 for this feature. Very helpful when trying to migrate from shared folder based nuget source to internal server. Issue occurs when the push is interrupted due to network issue and we have to retry the push again.

  10. darthscsi commented on Jun 7, 2017

    @darthscsi

    +1 for dealing with many packages. I have 100 packages and if a timeout happens, I can no longer use wildcards to upload the remaining. I have to try each one individually or generate a list of uploaded packages and exclude them from my set.

  11. 17 remaining items

  12. anangaur commented on Apr 15, 2019

    @anangaur

    When you are trying to push multiple package *.nupkg and do not want to be blocked when one of the pushes failed when the package is already present on the server, this option can come in handy. Especially for CI/CD scenarios when you are pushing intermediary bits to a private feed.

    Example: You publish a bunch of packages (say 10) to a private feed that does not allow overwriting packages as part of a build/release pipeline. One of the package in the bunch is malformed and hence after publishing 5 packages threw an error. So the push fails. Now you fix it and re-run the release. It should just skip (and not error) while pushing the 5 packages and then push rest of the 5 packages successfully. Note that servers may or may not allow you to overwrite and this option is to handle that situation.

    P.S.: I agree there are multiple ways to solve this issue on the server side or the client side or both. This is one of the ways.

  13. donnie-msft commented on Apr 16, 2019

    @donnie-msft
    Contributor

    As I see it, the server already does implement its portion of this by returning a specific error code for a duplicate. It's up to the client to decide if it cares or not. In the case of NuGet client, it always interprets it as a fatal error. The new option would allow you to customize NuGet client to say "it's okay, keep going". The server doesn't (and shouldn't) care whether you want to send further requests or not.

  14. infin8x commented on Apr 16, 2019

    @infin8x

    Thanks for taking this up! @donnie-msft that's right. We wrote our own custom client for Azure Pipelines to do just that. It's great to see it being taken up as a native NuGet feature.

  15. modified the milestones: 5.1, 5.2 on Apr 22, 2019
  16. changed the title [-]Commandline switch on nuget push to skip if already published[/-] [+]Skip Duplicate switch added to nuget.exe and dotnet.exe push command[/+] on Apr 22, 2019
  17. removed
    Priority:3
    on Apr 22, 2019
  18. changed the title [-]Skip Duplicate switch added to nuget.exe and dotnet.exe push command[/-] [+]Skip Duplicate switch added to nuget.exe push command[/+] on May 2, 2019
  19. modified the milestones: 5.2, 5.1 on May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions