7

I'm trying to push multiple nuget packages at ONCE to private VSTS nuget server.

I searched doco but could not find a batch Push command. I'm using the command below which seems to overwrite already existing nuget packages on VSTS.

nuget push mynuget.nupkg -Source https://myvsts.pkgs.visualstudio.com/DefaultCollection/_packaging/SitecorePackages/nuget/v3/index.json -ApiKey VSTS

UPDATE:

I used the push *.nupkg however, I can see only the 8.1.x version pushed.

enter image description here

Thanks.

Community
  • 1
  • 1
Nil Pun
  • 17,035
  • 39
  • 172
  • 294

3 Answers3

7

It's not possible to overwrite existing packages on VSTS. nuget.exe allows wildcards for push, so you could say nuget push *.nupkg -Source https://myvsts.pkgs.visualstudio.com/DefaultCollection/_packaging/SitecorePackages/nuget/v3/index.json -ApiKey VSTS.

Matt Cooper
  • 927
  • 9
  • 16
  • Thanks @MattCooper but when I tried with *.nupkg, it shows error message "Failed to process request: 'conflict'. The remote server returned 409 Confilct..." – Nil Pun May 14 '16 at 11:28
  • That's because it's not possible to overwrite the same package id + version. See this topic on [immutability](https://www.visualstudio.com/get-started/package/feeds/immutability). – Matt Cooper May 14 '16 at 12:35
  • Ok, I deleted and published 2 packages with *.nupkg. However, I can see only the last one. Somehow the last seems to override the first. See the screenshot attached on original post – Nil Pun May 15 '16 at 00:55
  • 3
    Recently, nuget push got the `-SkipDuplicate` argument to allow this to work. – Scott Stafford Jan 16 '20 at 19:41
7

Here is a powershell script you can use to bulk push NuGet packages to a VSTS feed. It will ignore any of the .symbols.nuget files:

set-location \\path\to\nugetpackages

$files=get-childitem | where {$_.Name -like "*.nupkg" -and $_.Name -notlike "*symbols*"}

foreach($file in $files) {
  .\NuGet.exe push -Source "MySource" -ApiKey key $file.name
}
TetraDev
  • 16,074
  • 6
  • 60
  • 61
5

First, I exclude previously uploaded packages from the "packages" folder and it contains only packages that not exists in local server. After that I use below command and it works fine.

nuget.exe push -Source "MyFeedName" -ApiKey VSTS packages\**\*.nupkg
AhmadYo
  • 334
  • 3
  • 6
  • 1
    I just used the same technique to bulk push everything from our old server to the new one - the `**` wildcard performs a recursive folder search and is really simple and useful for this. – Andy Hames Feb 22 '19 at 14:53
  • The backslashes are important. I mostly use forward slashes since it works on all platforms, but on windows this fails: packages/**/*.nupkg – pauldendulk Dec 30 '22 at 06:32