-
Notifications
You must be signed in to change notification settings - Fork 252
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 to GPR fails randomly #9775
Comments
There seem to be multiple issues describing this bug but they all seem to have been closed with unsatisfactory workarounds. The core issue is that the |
I've tried re-running the build and it fails randomly 4/5 times for the Schema.NET build but is rock solid for FastestNuGet. |
I've resorted to retrying to push a NuGet package to GitHub Actions. $count = 0;
do {
++$count;
dotnet nuget push .\*.nupkg --source GitHub --skip-duplicate;
}
while ($count -lt 30 -and $LastExitCode -ne 0) |
|
Removing it is not an option. |
Someone has written an entire dotnet global tool to workaround this bug: https://github.com/jcansdale/gpr There seem to be a lot of others experiencing the same issue: https://twitter.com/RehanSaeedUK/status/1281705870917881856?s=20 |
Try passing the This seems to make it work most of the time. Unfortunately I then see the odd error like this:
You can see what happens in the matrix run here: |
I second @jcansdale's gpr tool. It solved all my problems pushing to GH packages and I'm not worried about this issue anymore. I mean...the issue still needs to be dealt with, but I can at least move on with my life now. |
I'm dropping some notes here about the DescriptionStarting with .NET Core 2.1, the SocketsHttpHandler class provides the implementation used by higher-level HTTP networking classes such as HttpClient. The use of
By defining an environment variable named When
When
For this particular package, the first error seems to happen on |
After 9 failures in a row using DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER seems to have worked. Thank you @jcansdale. If it happens again I'll post any of the 400 warnings so this can be investigated more. |
@DamienDennehy interesting, thanks. Which OS are you using? The intermittent errors I was seeing when using this option where on Linux. |
Yeah it was Linux - Ubuntu. I'm using GitHub Actions to push and it was failing. Here's the push step: ` deploy-packages:
|
- adds an environment variable to disable SocketsHttpHandler and use legacy HttpClientHandler. Click [here](NuGet/Home#9775 (comment)) to read more.
I am having the same issue on Windows PowerShell 7 when using dotnet nuget add source https://nuget.pkg.github.com/OWNER/index.json --name "GitHub package" --username DEV --password $GITHUB_ACCESS_TOKEN --store-password-in-clear-text
dotnet nuget push "ThePackage.1.5.14.nupkg" --source "GitHub package" --skip-duplicate 99% of the time, the
But it seems that if I don't use nuget sources add -Source https://nuget.pkg.github.com/OWNER/index.json -Name "GitHub package" -Username DEV -Password GITHUB_ACCESS_TOKEN
nuget push "ThePackage.1.5.14.nupkg" -Source "GitHub package" -SkipDuplicate Reference: #8580 (comment) So I retried FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS base
ARG TECTAC_GITHUB_ACCESS_TOKEN
ENV DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
RUN dotnet nuget add source https://nuget.pkg.github.com/OWNER/index.json --name "GitHub package" --username DEV --password $GITHUB_ACCESS_TOKEN --store-password-in-clear-text
RUN find . -name "*.nupkg" | while read f; do dotnet nuget push ${f} --source "GitHub package" --skip-duplicate; done; It returned different error when it ran
And if I use the latest nuget CLI (5.7.0.6726) with mono on docker FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS base
ARG GITHUB_ACCESS_TOKEN
RUN apk upgrade && \
apk add --no-cache --update-cache mono --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing && \
cert-sync /etc/ssl/certs/ca-certificates.crt
ADD https://dist.nuget.org/win-x86-commandline/latest/nuget.exe /usr/local/bin/nuget.exe
ENV nuget="mono /usr/local/bin/nuget.exe"
ENV DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
RUN $nuget sources add -Source https://nuget.pkg.github.com/OWNER/index.json -Name "GitHub package" -Username DEV -Password $GITHUB_ACCESS_TOKEN -StorePasswordInClearText
RUN find . -name "*.nupkg" | while read f; do $nuget push ${f} -Source "GitHub package" -SkipDuplicate; done; I get
|
Thanks for sharing your investigations!
You say |
I've forked the You can see publishing randomly fails on If I change I wonder who might be able to investigate this further? |
@jcansdale I didn't save the only time it failed, but since then, all However since it was just for testing purposes and in my use case, I need to push through docker but both ARG TECTAC_GITHUB_ACCESS_TOKEN
RUN dotnet tool install -g gpr --no-cache -v q
RUN dotnet nuget add source https://nuget.pkg.github.com/OWNER/index.json --name "GitHub package" --username DEV --password $GITHUB_ACCESS_TOKEN --store-password-in-clear-text
RUN find . -name "*.nupkg" | while read f; do gpr push --api-key $TECTAC_GITHUB_ACCESS_TOKEN ${f}; done; |
Hi @RehanSaeed, You should find the following works fine now!
For some reason basic auth (password in the It's a mystery why Using the Thanks for your persistence on this issue! 🙏 |
@jcansdale is the change to support api key documented somewhere? |
FWIW, it finally got a mention in the GitHub Changelog but the docs for Configuring dotnet CLI for use with GitHub Packages still don't mention it. 🤔 |
I have the same problem. I am getting
Why does it complain about a 'RepositoryUrl' property? Do I really need a VS project? I merely have a .nupkg that I wanted to store. |
For whatever reason NuGet/Home#9775 re-appeared and this seems to fix it. Not really worth looking into further at this time since we'll be dropping .NET 5 soon anyway.
TL;DR try running A few months ago I was investigating a customer issue, and tried to use GPR for something. I was getting auth issues from GPR, so I opened Fiddler, and I found that NuGet wasn't sending credentials, because GPR wasn't sending the When pushing to V3 NuGet feeds, NuGet gets the "service index", to find the push URL, and then pushes the nupkg to that URL. However, NuGet will cache the service index, like all other GET requests that is not search, for up to 30 minutes. When the server index is stale, NuGet will request the service index, without authentication, GPR will respond with a 401, including the Therefore, if the push failures are due to missing auth, try deleting the HTTP cache just before every push, using |
This issue was most likely fixed in .NET 7. I don't experience this problem anymore. This is an example workflow |
Details about Problem
dotnet.exe --version:
3.1.301
OS version: GitHub Actions
windows-latest
- Microsoft Windows Server 2019 10.0.17763Detailed repro steps so we can see the same problem
I have two repos Schema.NET and FastestNuGet where I have the exact same
build.yml
file for GitHub Actions. However,dotnet nuget push
fails on one and succeeds on the other.The only difference I can understand is that one project has a
.
in the name and the other does not.Failing CLI Output
build.yml
The text was updated successfully, but these errors were encountered: