Closed jwillmer closed 4 years ago
@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 nuget sources add
command to add GPR as a source with the creds (GITHUB.TOKEN). See an example here: https://github.com/anangaur/entropy-packages/blob/master/.github/workflows/workflow.yml
steps:
- uses: actions/checkout@v1
- name: Setup Nuget.exe
uses: warrenbuckley/Setup-Nuget@v1
- name: Add GPR Source
run: nuget sources add -name "GPR" -Source https://nuget.pkg.github.com/anangaur/index.json -Username anangaur -Password ${{ secrets.GITHUB_TOKEN }}
- name: dotnet build
run: dotnet build
- name: nuget push
run: nuget push my.sample.lib\**\*.nupkg -Source "GPR" -SkipDuplicate
Btw, there is a typo in your yaml file. Look for use of nupk
instead of nupkg
(missing 'g').
warrenbuckley/Setup-Nuget@v1
only installs nuget for Windows. Using your workaround on Linux via sudo apt install nuget
does not work.
WARNING: No API Key was provided and no API Key could be found for 'https://nuget.pkg.github.com/NAME'. To save an API Key for a source use the 'setApiKey' command.
@jwillmer, you are right. We need to support dotnet sources
command: https://github.com/NuGet/Home/issues/4126
When I execute the following command: nuget push "ProjectFolder\nupkgs\MyPackage.1.0.0.nupkg" -Source "GitHub"
I get this error:
WARNING: No API Key was provided and no API Key could be found for 'https://nuget.pkg.github.com/Company'. To save an API Key for a source use the 'setApiKey' command.
Can anyone explain why? Since it's related with @jwillmer problem.
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 mono nuget.exe
to publish to GPR on the Ubuntu image.
Did you check my comment above https://github.com/NuGet/Home/issues/8580#issuecomment-531997703? 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:
name: Build & Publish nuget package
on:
push:
branches:
- release
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.0.100
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Setup nuget config
run: sed 's/GITHUB_TOKEN/${{ secrets.GITHUB_TOKEN }}/g' .nuget.config > nuget.config
- name: Publish nuget
run: dotnet nuget push src/bin/Release/*.nupkg -s "github"
The sed command simply copies the file to "nuget.config" and replaces "GITHUB_TOKEN" with the environment variable :slightly_smiling_face:
@anangaur I was doing pretty much the exact same thing but running nuget.exe on Mono, because the host is Ubuntu - https://github.com/mono/t4/commit/863011b731d9743033d6b371eb1c2719fe93293b
When will this be fixed ?
@mikkeljohnsen What are you blocked on? Restoring packages or publishing packages?
Did you check the current workarounds? https://github.com/NuGet/Home/issues/8580#issuecomment-542643681
@marza91 you don't need to install .NET Core 3.0 when using ubuntu-latest
in GitHub Actions, it is already there (the latest version, and also mono). So can safely remove this step:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.0.100
Btw, I use windows as a workaround for now: https://github.com/mono/t4/blob/573d5bb32be4b2b8ae13230cbc7eb56fcd9f9f99/.github/workflows/build.yml#L54-L58 https://github.com/linksplatform/Hardware.Cpu/blob/2e536836dd94dcfa8aa9840c99f50a9eb4a2c5a6/.github/workflows/main.yml#L42-L53
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
warn : No API Key was provided and no API Key could be found for 'https://nuget.pkg.github.com/COMPANY'. To save an API Key for a source use the 'setApiKey' command.
info: Pushing ...
error: An error occurred while sending the request.
error: The response ended prematurely.
I think the warning can be ignored since we provide user/pw in the NuGet file.
But I don't know if this error is because I already have the current version of the NuGet package deployed or if it is something else. In my version is used -SkipDuplicate
to ignore published duplicates but this is not possible with dotnet nuget
@anangaur
As you can see the first package is already uploaded and it reports correctly that there is a conflict.
warn : No API Key was provided and no API Key could be found for 'https://nuget.pkg.github.com/openmedicus'. To save an API Key for a source use the 'setApiKey' command.
info : Pushing OpenMedicus.WebService.Master.2.6.105.nupkg to 'https://nuget.pkg.github.com/openmedicus'...
info : PUT https://nuget.pkg.github.com/openmedicus/
warn : Error: Version OpenMedicus.WebService.Master of "2.6.105" has already been pushed.
info : Conflict https://nuget.pkg.github.com/openmedicus/ 445ms
error: Response status code does not indicate success: 409 (Conflict).
But pushing new packages almost always fails.
warn : No API Key was provided and no API Key could be found for 'https://nuget.pkg.github.com/openmedicus'. To save an API Key for a source use the 'setApiKey' command.
info : Pushing OpenMedicus.RosterHelper.2.6.105.nupkg to 'https://nuget.pkg.github.com/openmedicus'...
info : PUT https://nuget.pkg.github.com/openmedicus/
info : An error was encountered when fetching 'PUT https://nuget.pkg.github.com/openmedicus/'. The request will now be retried.
info : An error occurred while sending the request.
info : The response ended prematurely.
info : PUT https://nuget.pkg.github.com/openmedicus/
info : An error was encountered when fetching 'PUT https://nuget.pkg.github.com/openmedicus/'. The request will now be retried.
info : An error occurred while sending the request.
info : The response ended prematurely.
info : PUT https://nuget.pkg.github.com/openmedicus/
error: An error occurred while sending the request.
error: The response ended prematurely.
Somtimes I also get (this is using "nuget push" and not "dotnet nuget push" as above):
Pushing OpenMedicus.Data.2.6.105.nupkg to 'https://nuget.pkg.github.com/openmedicus'...
PUT https://nuget.pkg.github.com/openmedicus/
An error was encountered when fetching 'PUT https://nuget.pkg.github.com/openmedicus/'. The request will now be retried.
Error while copying content to a stream.
Unable to write data to the transport connection: The socket has been shut down.
The socket has been shut down
PUT https://nuget.pkg.github.com/openmedicus/
An error was encountered when fetching 'PUT https://nuget.pkg.github.com/openmedicus/'. The request will now be retried.
Error while copying content to a stream.
Unable to write data to the transport connection: The socket has been shut down.
The socket has been shut down
PUT https://nuget.pkg.github.com/openmedicus/
Error while copying content to a stream.
Unable to write data to the transport connection: The socket has been shut down.
The socket has been shut down
@mikkeljohnsen Are you using the right PAT while adding the GPR source? With nuget.exe you can run:
nuget sources add -name "GPR" -Source https://nuget.pkg.github.com/<account>/index.json -Username <user> -Password <PAT>
And for dotnet, see https://github.com/NuGet/Home/issues/8580#issuecomment-542643681
@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:
Pushing <PKG>.<VER>.nupkg to 'https://nuget.pkg.github.com/<ORG>'...
PUT https://nuget.pkg.github.com/<ORG>/
An error was encountered when fetching 'PUT https://nuget.pkg.github.com/<ORG>/'. The request will now be retried.
An error occurred while sending the request.
Unable to write data to the transport connection: The socket has been shut down.
The socket has been shut down
PUT https://nuget.pkg.github.com/<ORG>/
An error was encountered when fetching 'PUT https://nuget.pkg.github.com/<ORG>/'. The request will now be retried.
An error occurred while sending the request.
Unable to write data to the transport connection: The socket has been shut down.
The socket has been shut down
PUT https://nuget.pkg.github.com/<ORG>/
An error occurred while sending the request.
The server returned an invalid or unrecognized response.
/cc: @reybard ⬆️
Ha, well this is a bummer, I was just setting up azure pipelines for one of my projects and came accross this issue :/
Isn't GitHub Package Registry supposed to launch in about a week? Seems like it'll be a rocky launch, unless they can somehow fix all of these issues before then.
I just found out that it work if you use Curl:
curl -vX PUT -u "openmedicus:TOKEN" -F package=@OpenMedicus.Data.2.6.109.nupkg https://nuget.pkg.github.com/openmedicus/
thanks for the workaround @mikkeljohnsen good enough for cicd until they fix it x_x
I was just about to implement the workaround, but I noticed that at least on macOS-latest
(eg. Mojave + latest mono/msbuild/nuget), publishing with the nuget binary seems to work again?
Can anyone else confirm whether or not this works on macOS?
I think the underlying service for GitHub Package Registry is Azure Artifacts and I believe they did some announcements for the MS Ignite conference going on right now. So maybe they've just recently fixed some things?
I was just about to implement the workaround, but I noticed that at least on
macOS-latest
(eg. Mojave + latest mono/msbuild/nuget), publishing with the nuget binary seems to work again?Can anyone else confirm whether or not this works on macOS?
I'm on Catalina, I can't get any nupkgs to publish now with the nuget binary. I get the socket errors on push attempts. I think GPR is out of beta now?
The curl option does work though. :\
Yeah, turns out it only worked for me for a short while, and it's back to being broken again.
curl -vX PUT -u "openmedicus:TOKEN" -F package=@OpenMedicus.Data.2.6.109.nupkg https://nuget.pkg.github.com/openmedicus/
I'd like to try this out. Is there a way to save the nupkg name (OpenMedicus.Data.2.6.109.nupkg in this case) to a variable from the build step? That way the curl command can reference the variable rather than a hardcoded filename.
@vslee Not sure how your setup is. But I just build all my packages and move them to dir and run script with this:
#!/usr/bin/bash
for f in *.nupkg
do
curl -X PUT -u "openmedicus:`cat nugetpass`" -F package=@"$f" https://nuget.pkg.github.com/openmedicus/
done
I have a file named "nugetpass" in that directory, containing the TOKEN
Yes, that works for me. For reference of others, here is my code, using input from @mikkeljohnsen.
name: prerelease NuGet
on: [push]
jobs:
build:
runs-on: ubuntu-latest
# also works with windows-latest and macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v1
- name: Build with dotnet
run: dotnet build --configuration Release --version-suffix prerelease-$(date +%Y%m%d%H%M%S)
shell: bash
- name: Publish nuget
run: |
for f in ./[repository]/bin/Release/*.nupkg
do
curl -vX PUT -u "[user]:${{ secrets.GHPackagesToken }}" -F package=@$f https://nuget.pkg.github.com/[user]/
done
shell: bash
Notes:
<VersionPrefix>
instead of <Version>
in your .csproj<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
in your .csproj
dotnet pack
<RepositoryUrl>...</RepositoryUrl>
in your .csprojdotnet nuget push
command (see initial post), then we won't need this workaround anymoreI'm still unable to push any packages to GitHub and I have tried all the workarounds:
warn : The expected resource was not found.
I thought that maybe it was because I tried to get it to work with our Organization account, but I am also getting the error on my private account. Have anybody tried something like this?
@nnyegaard try creating a test repo w/ my solution. If it still doesn't work, post a link to the repo and I can take a look.
@vslee I got it working from your repo. I think I located the error, I did not specify the Repository URL in the csproj file for NuGet and without that nothing is happening. GitHub properly need to document that
Not a logical place to look for it, but the documentation actually mentions this under the "Publishing multiple packages to the same repository" topic: https://help.github.com/en/github/managing-packages-with-github-packages/configuring-nuget-for-use-with-github-packages#publishing-multiple-packages-to-the-same-repository
Github will try to derive the repo name from the package name, unless the repository url is specified. Usually you do this if you want to have multiple packages in the same repo, but I think it would be a good idea to also mention this in the "Publishing a package" topic, as not everyone is interested in publishing multiple packages.
I encountered this issue when using nuget/setup-nuget@v1 on ubuntu with the following steps:
- uses: nuget/setup-nuget@v1
with:
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
nuget-version: 'latest'
- name: Push package to the Github Package Registry
run: |
nuget sources Add -Name "GPR" -Source "https://nuget.pkg.github.com/lemorrow/index.json" -UserName LeMorrow -Password ${{ secrets.GITHUB_TOKEN }}
nuget setApiKey ${{ secrets.NUGET_API_KEY }} -Source "GPR"
nuget push nupkg\*.nupkg -Source "GPR" -SkipDuplicate
Simply changing runs-on: ubuntu-latest
to runs-on: windows-latest
for the job fixed this for me.
@rrelyea @zkat can you chime in on how to use setup-NuGet on Linux. Should this also use StorePasswordInClearText on platforms other than Windows, for it to work with Mono?
@LeMorrow are you still seeing this? I'm not. You shouldn't need setApiKey if you are using UserName and Password option. See my sample here that works and publishes to GPR: https://github.com/timheuer/test-lib/blob/master/.github/workflows/build-and-deploy.yaml. It's the same as yours minus the setApiKey which is not needed in this case.
@timheuer The issue is still the same for me after upgrading NuGet/setup-nuget to 1.0.2
and removing setApiKey
.
Results after just bumping the action version: https://github.com/LeMorrow/APOD.Net/runs/351453149#step:4:12
Results after removing the setApiKey
line:
https://github.com/LeMorrow/APOD.Net/runs/351536183#step:4:11
TL;DR: This
nuget sources Add -Name "GPR" -Source "https://nuget.pkg.github.com/lemorrow/index.json" -UserName LeMorrow -Password ***
nuget push nupkg/*.nupkg -Source "GPR" -SkipDuplicate
still throws the error
An error was encountered when fetching 'PUT https://nuget.pkg.github.com/lemorrow/'. The request will now be retried.
An error occurred while sending the request.
The server returned an invalid or unrecognized response.
PUT https://nuget.pkg.github.com/lemorrow/
but only on ubuntu-latest
. Not windows-latest
.
@LeMorrow wow, certainly looks the same as mine and I'm not having issues. I wonder if you delete https://github.com/LeMorrow/APOD.Net/blob/master/.github/workflows/deploy.yml#L58 if that makes any difference. I can't imagine why it would and odd that you are seeing this just on ubuntu-latest. Also perhaps add -Verbosity detailed
to see if anything more from nuget.exe comes across.
@timheuer Odd indeed! Removing line 58 did not make a difference as you hypothesized. The detailed verbosity provided a stack trace, hopefully that will be useful for anyone taking a look at this. Let me know if there's anything else I can do to help reproduce/debug this issue :)
Here's the result without line 58 and detailed verbosity: https://github.com/LeMorrow/APOD.Net/runs/352456423#step:4:1
I've been struggling with this issue also; this is where I have ended up for now: https://github.com/bitthicket/AspNetCore/blob/master/.github/workflows/nuget_release.yml
And the latest results from this workflow:
I've tried everything suggested in this thread and I'm just at a loss.
@aggieben did you try my solution?
@vslee parts of it. I have some other moving parts that are different and would be tedious to change. For example, I'm using paket to build my project and package, executed from a fake script.
Update: I did try to use the curl command just now, and it failed in the same way:
(although the exit code was apparently success? maybe because of invoking through the bash shell...)
Since you're using a different build system, are you sure that the .nupkg is in ./temp/*.nupkg? Can you do a 'ls' command there to verify?
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.