The documentation is not complete and currently I cannot consume or publish package to GPR using dotnet on Mac. Any help would be useful
Asked
Active
Viewed 2,972 times
4
-
I think it is not a 'Mac' issue but a 'dotnet' issue, regardless of the operative system, I can't confirm right now, as I don't have Windows machine around, consider changing the question title to 'using dotnet-cli' instead of 'dotnet on mac' – Dan Oct 20 '19 at 07:21
3 Answers
4
Far from ideal, and I haven't tested on Mac yet, but it worked on Linux
Publish
- Enable GPR 'feature' in your GitBHub settings
- Go to github and add a TOKEN with GPR read/write access
Add source locally
nuget source Add -Name "GitHub" \ -Source "https://nuget.pkg.github.com/MY_ACCOUNT/index.json"
Set api key
nuget setApiKey $TOKEN \ -Source "https://nuget.pkg.github.com/MY_ACCOUNT/index.json"
Push package
nuget push "my.lib.nupkg" -Source "GitHub"
Install package
nuget install my.lib -pre # '-pre' because of alpha, if alpha
Note: 'nuget install' downloads the nuget package It doesn't add it to the project. 'dotnet' can't find it Do it anyway so it gets cached in `~/.nuget/packages` The `./project` relative downloaded package can be deleted
Reference manually:
Add 'new Source' to nuget.config.
<add key="GitHub" value="https://nuget.pkg.github.com/MY_ACCOUNT/index.json" />
nuget config can be
- './nuget.config'
- '~/.nuget/NuGet/nuget.config'
Add to project:
dotnet add package my.lib \
-v 1.0.0-alpha \
-n # don't download, it can't handle authentication
Alternatively:
Edit project package reference
<PackageReference Include="my.lib" Version="1.0.0-alpha" />
Finally:
dotnet restore

Dan
- 2,818
- 23
- 21
2
As you can see at this link to the github community question dotnet nuget is currently not supported by the GPR and you rather have to use nuget with Mono or publish from Windows.
I hope they'll fix it in the near future myself, it's completely stopping me from taking advantage of the GPR.

Mortimer
- 21
- 1
-
Your post saved me from continuing to bang my head against the wall on a Linux machine. The understandable frustration is apparent in the thread you linked. – ForeverZer0 Sep 16 '20 at 22:11
2
You'll have to make the HTTP call yourself (other steps omitted for brevity):
jobs:
continuous-integration:
runs-on: ubuntu-latest
steps:
- name: push
run: |
for f in ./packages/*.nupkg
do
curl -vX PUT -u "<YOUR USER NAME>:${{ secrets.GITHUB_TOKEN }}" -F package=@$f https://nuget.pkg.github.com/<YOUR USER NAME>/
done
if: github.event_name == 'push'

João Bragança
- 1,353
- 1
- 13
- 29