I've succeeded in setting up a GitHub action that builds and packs my multi-target NuGet package.
name: .NET Core
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1.5.0
with:
dotnet-version: 3.1.301
# Authenticates packages to push to GPR
source-url: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
env:
NUGET_AUTH_TOKEN: '%NUGET_AUTH_TOKEN%'
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.0.1
- name: Install dependencies
run: msbuild /t:Restore
env:
NUGET_AUTH_TOKEN: ${{ github.token }}
- name: Build
run: msbuild /t:Pack /p:Configuration=Debug Library/MintPlayer.MVVM/MintPlayer.MVVM.csproj
- name: Copy
run: copy Library/MintPlayer.MVVM/bin/Debug/*.nupkg .
- name: PushNuget
run: dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.PUBLISH_TO_NUGET_ORG }} --skip-duplicate
- name: PushGithub
run: dotnet nuget push *.nupkg --no-symbols --skip-duplicate
env:
NUGET_AUTH_TOKEN: ${{ github.token }}
Since this is a Xamarin.Forms package, I need to use the MSBuild SDK.
The restore, build and pack commands are working fine. I cannot use the p:OutputPath
parameter for multi-target nuget packages (Issue can be tracked here). That's why I have a step to build, and copy the file to the %cd%
.
The push to nuget.org works as expected, but the push to my github feed fails with the following result:
I cannot find out what's going wrong here. Does anyone have an idea of why the push to GitHub is failing?
Also here is an example of a successful push to GPR, so the warning about the API key not being provided is not the cause of the issue: