see also https://github.com/dotnet/cli/issues/5436
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.
dotnet nuget push *.nupkg
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
$ 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.
Very helpful if you can zip a project and paste into this issue!
No need sample project.
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 {}
any update on this one? seems to be still an issue on dotnet --version: 2.1.101
This is still an issue, only one nuget gets uploaded when running dotnet nuget push /nupkgs/*.nupkg
try; dotnet push **\*.nupkg
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 ?
my last post/error/finding can be solved by adding
-n (--no-symbol) option BUT ATTENTION
there is another bug in the commandline parser (https://github.com/NuGet/Home/issues/4864)
thet requires the syntax "-n true"
error: File does not exist (*/.snupkg).
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
This Project is the CORE of dotnet !?
sorry i'm disappointed....
regards
Werner
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
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.
Running into this at this moment in time. I am going to try one of the workarounds suggested in this thread. I agree with others on this thread. This is core and should be fixed sooner rather than later. Given that this is going on for over 3 years now, frustrating.
I don't mean to sound flippant, and I don't like it when people say "we're open source, send us a PR", but I think this issue should be simple enough for a community member who is willing to spend some time to investigate. I'll even give background information to help get started:
I'm fairly confident this stems from the fact that cmd.exe
and powershell on Windows do not do file globbing, meaning if I run program.exe *.nupkg
, in this case program.exe
's Main(string[] args)
will have args.Length == 1 && args[0] == "*.nupkg"
. This means on Windows, every application, including NuGet, has to do its own file globbing. Whereas using other shells, such as Bash, args.Length
will equal the number of files in the current directory with the extension nupkg
, because the shell itself does globbing and expands before executing the program. It appears the developers who implemented NuGet's push commands did not take this into account: https://github.com/NuGet/NuGet.Client/blob/ce6d944538b1b587d87daa4163b8934069360d23/src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/PushCommand.cs#L90
https://github.com/NuGet/NuGet.Client/blob/ce6d944538b1b587d87daa4163b8934069360d23/src/NuGet.Clients/NuGet.CommandLine/Commands/PushCommand.cs#L48
Anyone willing to make a contribution should start looking at these two locations.
We have another thread on the same topic, which I can't at the moment, where others confirmed that on Linux/Mac (where shells do globbing by default), you can work around the issue by running dotnet push '*.nupkg'
. By putting the *
in single quotes, it tells the shell not to glob and pass directly to the program unmodified, so that it mimicks the two shells available on Windows by default, and runs NuGet's internal file globbing.
Thank you @zivkan
I wonder it has been three years since I created this issue and this issue looks too old. It sounds good to sort out the issues.
Originally, I created this ticket dotnet nuget push *.nupkg
doesn't push more than one file on "Linux". However, @zivkan says it now works on Linux but doesn't on Windows. Is my understanding correct?
If so, let's sort out which platform doesn't work on dotnet nuget push *.nupkg
at first. I'll check it on my side but any comment is appreciated.
If this issue happens only on Windows now, I can file a PR to fix these files.
https://github.com/NuGet/NuGet.Client/blob/ce6d944538b1b587d87daa4163b8934069360d23/src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/PushCommand.cs#L90
https://github.com/NuGet/NuGet.Client/blob/ce6d944538b1b587d87daa4163b8934069360d23/src/NuGet.Clients/NuGet.CommandLine/Commands/PushCommand.cs#L48
Hi @zivkan
As far as I tested on Windows, WSL, and macOS, this issue still happens not on Windows but on "Linux" and "macOS".
I'd like to file a pull request if you help to point where the code is.
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.
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.
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.
I'm closing this issue with summarizing as follows.
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.
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.
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.
https://github.com/NuGet/Home/issues/4393#issuecomment-660504976
As this looks like a "good-to-have" feature for me, I don't file this feature request right now.
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.
Most helpful comment
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.