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

dotnet nuget push *.nupkg doesn't push more than one file #4393

Closed
Tracked by #6285
tanaka-takayoshi opened this issue Jan 24, 2017 · 18 comments · Fixed by NuGet/NuGet.Client#3739
Closed
Tracked by #6285

dotnet nuget push *.nupkg doesn't push more than one file #4393

tanaka-takayoshi opened this issue Jan 24, 2017 · 18 comments · Fixed by NuGet/NuGet.Client#3739
Assignees
Labels
Functionality:Push help wanted Considered good issues for community contributions. Priority:2 Issues for the current backlog. Product:dotnet.exe Type:Bug

Comments

@tanaka-takayoshi
Copy link

see also https://github.com/dotnet/cli/issues/5436

Details about Problem

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): dotnet (on Linux)

NuGet version (x.x.x.xxx): seems RC4 (I have no idea to confirm it)

dotnet.exe --version (if appropriate): 1.0.0-rc4-004598

VS version (if appropriate):NA

OS version (i.e. win10 v1607 (14393.321)):RHEL 7.3

Worked before? If so, with which NuGet version:No.

Detailed repro steps so we can see the same problem

  1. Install dotnet SDK daily build package
  2. locate 2 different nupkg files
  3. set up NuGet Server and API key as you can push nupkg to NuGet Server
  4. run dotnet nuget push *.nupkg
  5. Only one nupkg file is uploaded.

Other suggested things

I expect I can push all the nupkg files.
https://docs.microsoft.com/en-us/dotnet/articles/core/preview3/tools/dotnet-nuget-push

$  /opt/dotnet/dotnet --info
.NET Command Line Tools (1.0.0-rc4-004598)

Product Information:
 Version:            1.0.0-rc4-004598
 Commit SHA-1 hash:  1dfee9ead8

Runtime Environment:
 OS Name:     rhel
 OS Version:  7.3
 OS Platform: Linux
 RID:         rhel.7.2-x64
 Base Path:   /opt/dotnet/sdk/1.0.0-rc4-004598

Verbose Logs

$ ls
libuv.1.9.1.nupkg  Microsoft.AspNetCore.WebUtilities.1.0.0.nupkg
$  /opt/dotnet/dotnet nuget -v Verbose push *  -k <NuGetKey> -s <NuGetServer>
trace: NuGet Command Line Version: 4.0.0.0
info : Pushing libuv.1.9.1.nupkg to '<NuGetServer>'...
info :   PUT <NuGetServer>
info :   Created <NuGetServer> 3215ms
info : Your package was pushed.

Sample Project

Very helpful if you can zip a project and paste into this issue!
No need sample project.

@rrelyea rrelyea added this to the 4.0.1 milestone Jan 25, 2017
@tanaka-takayoshi tanaka-takayoshi changed the title dotnet nuget push *.nupkg in "" doesn't push more than one file dotnet nuget push *.nupkg doesn't push more than one file Jan 25, 2017
@rrelyea rrelyea added Functionality:Push Type:Bug Priority:1 High priority issues that must be resolved in the current sprint. Priority:2 Issues for the current backlog. and removed Priority:1 High priority issues that must be resolved in the current sprint. labels Jan 27, 2017
@singlewind
Copy link

singlewind commented May 11, 2017

I can confirmed this within microsoft/aspnetcore-build:1.0-1.1

At the moment, I use the following line in linux as workaround inside the above build container.
find obj/Docker/publish -name '*.nupkg' | xargs -i dotnet nuget push {}

@zhili1208 zhili1208 modified the milestones: Future-0, Backlog Nov 9, 2017
@stephenlautier
Copy link

any update on this one? seems to be still an issue on dotnet --version: 2.1.101

@jessepiccolo
Copy link

This is still an issue, only one nuget gets uploaded when running dotnet nuget push /nupkgs/*.nupkg

Jjagg added a commit to Jjagg/OpenWheels that referenced this issue Jul 27, 2018
There's a bug in NuGet that causes only the first matching package to be
pushed. Somehow the command works fine locally, but CI only pushes
OpenWheels. Hopefully this works around that issue.

Related ticket: NuGet/Home#4393
@MatthijsKrempel
Copy link

try; dotnet push **\*.nupkg

@WernerMairl
Copy link

i can confirm "dotnet push **/*.nupkg" (linux slash, instead of windows backslash) basically is working. push is executed (i see my packages on NuGet.Org!

BUT command ends with exitcode and the last3 output rows:

info :   Created https://www.nuget.org/api/v2/package/ 590ms
info : Your package was pushed.
error: File does not exist (**/*.snupkg).

it seems that some symbol settings now are required.
i'm not using symbol features untilt now, so i don't expect this exception... may be a breaking change ?

  • dotnet --info
    .NET Core SDK (reflecting any global.json):
    Version: 2.2.103
    Commit: 8edbc2570a
    Runtime Environment:
    OS Name: debian
    OS Version: 9
    OS Platform: Linux
    RID: debian.9-x64
    Base Path: /usr/share/dotnet/sdk/2.2.103/
    Host (useful for support):
    Version: 2.2.1
    Commit: 878dd11e62
    .NET Core SDKs installed:
    2.2.103 [/usr/share/dotnet/sdk]
    .NET Core runtimes installed:
    Microsoft.AspNetCore.All 2.2.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
    Microsoft.AspNetCore.App 2.2.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
    Microsoft.NETCore.App 2.2.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
    To install additional .NET Core runtimes or SDKs:
    https://aka.ms/dotnet-download

@WernerMairl
Copy link

my last post/error/finding can be solved by adding
-n (--no-symbol) option BUT ATTENTION
there is another bug in the commandline parser (#4864)
thet requires the syntax "-n true"

error: File does not exist (**/*.snupkg).

@WernerMairl
Copy link

Personal note:

coming back to work more with NuGet (Client) after two years and i must see:
no progress in core quality/stability....

i'm using core features (NuGet push) and after 2 hours of work i run into 2 open issues

  • "dotnet nuget push **/*.nupkg" shows different behavior then "dotnet nuget push concrete.nupkg" regarding snupkg (a new feature that adds some regression ?)
  • dotnet nuget push -n is not working like spec (needs a dummy value....

This Project is the CORE of dotnet !?

sorry i'm disappointed....

regards
Werner

@WeihanLi
Copy link

WeihanLi commented Apr 4, 2019

A solution here? And any plan to fix this?

I find dotnet nuget push *.nupkg works normally on *unix os enviroment but on windows environment, it will also push *.snupkg

airbreather added a commit to NetTopologySuite/NetTopologySuite.IO.SpatiaLite that referenced this issue Jun 2, 2019
@dbsanfte
Copy link

dbsanfte commented Nov 5, 2019

It's shocking that dotnet nuget push *.nupkg is still broken after all this time. This is trivial stuff that you don't expect to be broken in a core product.

If you won't fix it, error out and explain why, don't proceed with broken behaviour.

WebGL3D added a commit to tix-factory/nuget that referenced this issue Nov 24, 2019
ckuetbach added a commit to d-velop/dvelop-sdk-cs that referenced this issue Dec 4, 2019
@aortiz-msft aortiz-msft added Category:Quality Week Issues that should be considered for quality week and removed Category:Quality Week Issues that should be considered for quality week labels Mar 12, 2020
JanWichelmann added a commit to JanWichelmann/MoodleLti that referenced this issue Jul 10, 2020
JanWichelmann added a commit to JanWichelmann/MoodleLti that referenced this issue Jul 10, 2020
@zivkan
Copy link
Member

zivkan commented Jul 19, 2020

However, @zivkan says it now works on Linux but doesn't on Windows. Is my understanding correct?

No, I'm saying that NuGet only uses a single filename, as shown by the two lines of code I linked. The operating system doesn't matter.

If that filename contains a *, NuGet does its own file globbing (search the filesystem for files that match the pattern, then expand the selection to include them all), and can therefore find multiple files. However, if you run nuget push a.1.0.0.0.nupkg b.1.0.0.0nupkg, it doesn't matter what operating system, or shell, you're using. NuGet will only push the first nupkg, because NuGet only looks at args[0].

There's a misunderstanding that it's related to Windows or Linux. It's actually the shell. Scott Hanselman has a blog post which explains the difference between terminal, console and shell, which might help with the understanding. If you run a shell on Windows that does file globbing, you'll have the same problem as people "using linux". If you configure your shell on linux to stop doing globbing (or you quote '*.nupkg', to tell the shell to pass it as a string literal), you'll get the same behaviour "as windows".

Another way to look at it is to forget about nuget for a few minutes. Try out this Program.cs:

class Program
{
  void Main(string[] args)
  {
    System.Console.WriteLine("Number of arguments: " + args.Length);
    for (int i = 0; i < args.Length; args++)
    {
      System.Console.WriteLine($"[{i}]: {args[i]}");
    }
  }
}

Try running this with dotnet app.dll * or dotnet app.dll *.* on powershell and bash (git bash or WSL, doesn't matter). See how the different shells pass different values to your app, despite typing in the exact same command line.

So, NuGet needs to be changed in the two places I linked earlier where it does var nupkgPath = args[0]. It needs to be able to handle a list of file paths being provided, rather than just one. At some point NuGet expands the * into multiple files, so the rest of NuGet handles a list of files just fine. Just the bit between args[0] and the expanded file list needs to be improved.

@tanaka-takayoshi
Copy link
Author

Thanks @zivkan . I found I was misunderstanding.

The issue I was facing is not a cross-platform issue but the difference of shell. To avoid the issue, I can just simply avoid globbing in bash (or another shell).

dotnet nuget push "*.nupkg"

Now that I think this is not a bug in NuGet while I considered this was a bug when creating this issue. To avoid misunderstanding like me, how about adding an extra note in the NuGet document to take care of the globbing in a shell.

I'm also thinking I'm going to close this issue and creating a new issue to support multiple files to push.

@ChiefInnovator
Copy link

ChiefInnovator commented Jul 19, 2020

I am using Linux Ubuntu builds from GitHub. My team and I ran into this several times. We haven't been able to get anything other than specifying the files directly or using xargs. Fortunately the xargs works great. We have tried several combinations .nupkg, out/.nupkg, and more.

No wildcards have worked properly. What is happening is that it picks up the very first package and then doesn't do anything else. We have a handful of packages to deploy. Using *.nupkg in any combination just works only for one package.

We are however able to use a command line to do a *.nupkg, pass to xargs to run dotnet nuget push. So wildcards are working on the command line, just not from dotnet nuget push.

Interesting is that GitHub uses this in their workflow template for publishing .NET Core packages. I think the best thing is to get GitHub to update the workflow template. That way others will not run into this issue as much.

@tanaka-takayoshi
Copy link
Author

I'm closing this issue with summarizing as follows.

The target of this issue

When trying to push two or more nuget files by dotnet nuget push *.nupkg on Linux or macOS, only one nuget file was pushed.
If your issue is happening also on Windows, please open another issue. It seems to be other than this issue, but might be related.

How to solve

Please use dotnet nuget push "*.nupkg" or another similar way to avoid shell file globbing.
As zivlan explained, it's not NuGet CLI issue but shell issue.

Background

When we use dotnet nuget push *.nupkg command in bash or other similar shells if there're two nupkg files, A.nupkg and B.nupkg, NuGet CLI receives dotnet nuget push A.nupkg B.nupkg due to file globbing. NuGet CLI doesn't support specifying two or more files such as dotnet nuget push [file1] [file2].
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push

If you think NuGet should support specifying two or more files, everyone can open another issue as a feature request.
#4393 (comment)

As this looks like a "good-to-have" feature for me, I don't file this feature request right now.

@zivkan
Copy link
Member

zivkan commented Aug 6, 2020

I'm reopening this issue. Even though the original author, @tanaka-takayoshi has worked around the issue. Many others are hitting it and this issue is now the preferred tracking issue to add support into NuGet to pass multiple nupkgs on the command line. Everyone interested should keep upvoting the original post so that it appears higher in the list of all open issues sorted by upvotes.

This issue should not be closed until NuGet supports multiple files passed on the command line.

@zivkan zivkan reopened this Aug 6, 2020
@zkat zkat removed this from the Backlog milestone Sep 2, 2020
@donnie-msft donnie-msft self-assigned this Oct 29, 2020
akunzai added a commit to akunzai/NHibernate.Extensions.Logging that referenced this issue Jan 20, 2021
akunzai added a commit to akunzai/GSS.Authentication.CAS that referenced this issue Jan 20, 2021
akunzai added a commit to akunzai/GSS.Authorization.OAuth that referenced this issue Jan 20, 2021
jaredpar added a commit to jaredpar/basic-reference-assemblies that referenced this issue Jan 29, 2021
jaredpar added a commit to jaredpar/basic-reference-assemblies that referenced this issue Jan 29, 2021
csharpjsdev added a commit to csharpjsdev/reference-assemblies that referenced this issue Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Push help wanted Considered good issues for community contributions. Priority:2 Issues for the current backlog. Product:dotnet.exe Type:Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.