-
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 -- Invalid or unrecognized response #8580
Comments
@anangaur - has your experience with GPR given you wisdom on how to reply here? |
/cc: @infin8x Unfortunately, GPR does not work with API keys as we would have expected it to work. I have provided this feedback to GitHub. You would need to use
Btw, there is a typo in your yaml file. Look for use of |
|
When I execute the following command: I get this error: Can anyone explain why? Since it's related with @jwillmer problem. |
Please read the thread and you will find your answer. |
@rrelyea, It should work in non-windows builds. Would you please change this as a bug and not a question? Thanks in advance. |
I'm also seeing this using |
Did you check my comment above #8580 (comment)? Does it work? |
Managed to get this working for linux by creating a nuget.config "template" in my repo like this one: https://gist.github.com/marza91/06dd1a8af3abd85dd0c1972f22bbfc2d I added this file (replace "ourcompany" with your user/org) to the base of the repo as ".nuget.config", and then simply did the following:
The sed command simply copies the file to "nuget.config" and replaces "GITHUB_TOKEN" with the environment variable 🙂 |
@anangaur I was doing pretty much the exact same thing but running nuget.exe on Mono, because the host is Ubuntu - mono/t4@863011b |
When will this be fixed ? |
@mikkeljohnsen What are you blocked on? Restoring packages or publishing packages? Did you check the current workarounds? #8580 (comment) |
@marza91 you don't need to install .NET Core 3.0 when using
Btw, I use windows as a workaround for now: But it would be much better to have it working on linux too, I don`t want to use separate job for just this steps. |
@Konard TBH though I was annoyed by this initially, after I set up a matrix build I'm fine with having it in a later job, because that way the package only gets uploaded if all the matrix builds pass |
@anangaur I'm not familiar with that. But I assume it is something that is done on GitHub after you push your code to the branche "release". I do not build my NuGet packages with dotnet/msbuild. I have +200 projects in my solution and using MSBuild is simple a pain, not to mention using NuGet for all +200 projects. It is simple to slow. I use Makefiles (and mono "csc") to build my projects and also create NuGet packages with "nuget pack *.nuspec" and the "nuget push" to upload. But the "nuget push" is failing. I'm on Linux (Fedora 30). Using Mono 6.0. |
So now "dotnet nuget push *.pkpkg -s GitHub", works sometimes. I have uploaded 2 packages out of 20. So just have to run the command a 100 times, then maybe all packages will be successfully uploaded :) Must be something wrong with the GitHub server, since it works sometimes. |
@mikkeljohnsen intermittent failures are hard to fix. Can you paste the error messages you have been getting? |
I tried @marza91 script but I get
I think the warning can be ignored since we provide user/pw in the NuGet file. |
As you can see the first package is already uploaded and it reports correctly that there is a conflict.
But pushing new packages almost always fails.
Somtimes I also get (this is using "nuget push" and not "dotnet nuget push" as above):
|
@mikkeljohnsen Are you using the right PAT while adding the GPR source? With nuget.exe you can run:
And for dotnet, see #8580 (comment) |
@anangaur Yes I do. I have managed to upload 2 packages. It is a TOKEN you have to use, and it has all the possible security rights set. |
So does this only work reliably on Windows, while macOS and Linux only work intermittently? I've yet to see pushing work at all on macOS. Not locally and not on a CI/GitHub Actions. It almost sounds like the NuGet specific endpoint/service is stuck in an exception loop:
|
Also been through a few iterations and approaches to this. Sometimes the following works, other times I get errors: - name: Publish to github
run: dotnet nuget push **/*.nupkg -s https://nuget.pkg.github.com/[USERNAME]/index.json -k ${{ secrets.GITHUB_TOKEN }} --skip-duplicate --no-symbols true
working-directory: src [intermittent] errors with: An error was encountered when fetching 'PUT https://nuget.pkg.github.com/daltskin/'. The request will now be retried. An error occurred while sending the request. Now, I'm just using curl to push the package and it seems more reliable :) Replace Github workflow extract: - name: Package
run: dotnet pack --configuration Release --no-build -p:PackageVersion=${{ env.GitVersion_SemVer}}
- name: Publish to github (using curl)
run: curl -vX PUT -u "[USERNAME]:${{ secrets.GITHUB_TOKEN }}" -F package=@[PACKAGE].${{ env.GitVersion_SemVer}}.nupkg https://nuget.pkg.github.com/[USERNAME]/
working-directory: src/bin/Release |
I have two repos where I'm using the exact same
name: Build
on:
push:
pull_request:
release:
types:
- published
env:
# Set the DOTNET_SKIP_FIRST_TIME_EXPERIENCE environment variable to stop wasting time caching packages
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending usage data to Microsoft
DOTNET_CLI_TELEMETRY_OPTOUT: true
# Set the build number in MinVer
MINVERBUILDMETADATA: build.${{github.run_number}}
jobs:
build:
name: Build-${{matrix.os}}
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
lfs: true
fetch-depth: 0
- name: 'Git Fetch Tags'
run: git fetch --tags
shell: pwsh
- name: 'Install .NET Core SDK'
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.301
- name: 'Dotnet Tool Restore'
run: dotnet tool restore
shell: pwsh
- name: 'Dotnet Cake Build'
run: dotnet cake --target=Build
shell: pwsh
- name: 'Dotnet Cake Test'
run: dotnet cake --target=Test
shell: pwsh
- name: 'Dotnet Cake Pack'
run: dotnet cake --target=Pack
shell: pwsh
- name: 'Publish Artefacts'
uses: actions/upload-artifact@v1.0.0
with:
name: ${{matrix.os}}
path: './Artefacts'
push-github-packages:
name: 'Push GitHub Packages'
needs: build
if: github.ref == 'refs/heads/master' || github.event_name == 'release'
runs-on: windows-latest
steps:
- name: 'Download Artefact'
uses: actions/download-artifact@v1
with:
name: 'windows-latest'
- name: 'Dotnet NuGet Add Source'
run: dotnet nuget add source https://nuget.pkg.github.com/RehanSaeed/index.json --name GitHub --username RehanSaeed --password ${{secrets.GITHUB_TOKEN}}
shell: pwsh
- name: 'Dotnet NuGet Push'
run: dotnet nuget push .\windows-latest\*.nupkg --source GitHub --skip-duplicate
shell: pwsh |
try fix for nuget via NuGet/Home#8580 (comment)
I got it working with |
I'm using my nuget action under an organization and this is what's been working for us after many trial and errors. - name: Publish backend nuget
run: curl -vX PUT -u "user:${{ secrets.package_secret }}" -F package=@Publish/backend.${{env.VERSION}}.nupkg https://nuget.pkg.github.com/myorg/
shell: bash
working-directory: ${{env.backend-directory}}
- name: Publish frontend nuget
run: curl -vX PUT -u "user:${{ secrets.package_secret }}" -F package=@Publish/backend.${{env.VERSION}}.nupkg https://nuget.pkg.github.com/myorg/
shell: bash
working-directory: ${{env.frontend-directory}} |
I know this issue is closed, but I continue to see issues with the methods mentioned above. One time it works and then another time it doesn't. I am also working under and organization. This is SO Frustrating! |
Hey All, I can understand this can be frustrating. For the team to have visibility and help here, I have created a new issue: Please provide your experience/issues and upvotes on this new issue. Hope this helps. |
I reached out to GitHub Enterprise Support and here's what they shared with me:
Here is how I used the GPR Tool in my GitHub Action and it worked the first time!
|
@Airn5475 gpr might not be an option for some users like me. Something not everybody knows is that nuget.config files are evaluated in cascade from the root directory to the current directory. So nuget.config files in between the root and the current directory can add, remove or override existing properties. I use this particular behaviour to split the login keys and the actual nuget server in two separated nuget.config files, so I can add the nuget.config with the servers to the repository, and leave the nuget.config with the login keys out of it. nuget cli app and visual studio handles this feature perfectly, whereas gpr only reads the properties of the first nuget.config it finds. In fact, I suspect this way of handling nuget.configs is one of the reasons because it works for some users, and not for others. |
@vpenades I hear you, this isn't for everyone, but I saw others in the comments above having trouble with dotnet push and so I thought it best to share my solution. Better to perhaps help some then for sure help none, right? I am aware of the nuget.config cascade and have wrestled with it a couple times. That was not my issue this time since my files were all in order and a repo that HAD been publishing nuget packages fine, stopped working. I can't speak to others, but gpr fixed my issue today! |
More recently I've noticed a general improvement in the frequency of success messages vs. failure messages. I've also found that in the few instances that it doesn't work, going away for a coffee and coming back 10 minutes later to retry is usually sufficient to achieve a successful push. Not an ideal solution, but at least you get a coffee out of it! Anyway, I've included both my
You could revamp the deploy-package script for other folder arrangements, but this was ideal for my team's workflow. Anyway, here are the files (replace repo name as required):
Just a note for those who've never had to set environment variables, it's very straightforward. Simply follow the steps below:
Just a final comment that Visual Studio can interfere with NuGet.config file! If working in Visual Studio, you can avoid needing the NuGet.config file altogether by running the following command in PowerShell (just a one-time thing!) and you set a system-wide source setting that will work across VS, PowerShell Core, Windows PowerShell etc:
The deploy-package script will still work as expected. This source setting is saved here on Windows: This issue is intermittent, but the info above should increase your odds of success until it's fixed! If at first you don't succeed, get a coffee and try later ;) Cheers. |
I was able to make it work using the following command:
Previously, using My <?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="github" value="https://nuget.pkg.github.com/ORGANIZATION_NAME/index.json" />
</packageSources>
<packageSourceCredentials>
<github>
<add key="Username" value="%GITHUB_USERNAME%" />
<add key="ClearTextPassword" value="%GITHUB_TOKEN%" />
</github>
</packageSourceCredentials>
</configuration> |
Hi @jwillmer, You should find the following works fine now: - name: Publish Nuget to GitHub registry
run: dotnet nuget push ./MyNugetPackage.3.4.24.nupk -k ${GITHUB_TOKEN} -s https://nuget.pkg.github.com/USERNAME/index.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} Support for the |
@jcansdale I referenced your solution on stackoverflow: How to push nuget package in GitHub actions |
Thanks for the heads up! BTW, your example workflow can now look like this (no need for - name: Setup .NET Core @ Latest
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
- name: Build solution and generate NuGet package
run: |
cd <project>
dotnet pack -c Release -o out
- name: Push generated package to GitHub registry
run: dotnet nuget push ./<project>/out/*.nupkg --source https://nuget.pkg.github.com/<owner> --api-key ${{github.token}} --skip-duplicate --no-symbols true |
using the API key should be supported now, see NuGet/Home#8580
Just leaving my solution here since I stumbled across this while googling for solutions. I am not using a When I was getting the api-key error (as others have described above), there was a second error message after it related to
Apparently this needs to be the URL to the repo this action is running for. I set my value as above and then used a small
After doing these steps the publish was successful, but I was still getting a warning because of the missing api key. I added this to the Here's my final (anonymized) workflow:
Hope this helps someone out there. |
Also change command style: NuGet/Home#8580
Error: UserName: Password: Unauthorized https://nuget.pkg.github.com/hochfrequenz/ 564ms Response status code does not indicate success: 401 (Unauthorized). Try to keep as close as possible to NuGet/Home#8580
I run the following script in GitHub Actions:
and I get the following output:
I'm running my code inside of
ubuntu-latest
(18.04) that has the following versions installed: software-in-virtual-environments-for-github-actionsCan someone help me explain what this error means? I don't know how to solve this.
The text was updated successfully, but these errors were encountered: