I have a class library project that I keep in a private GitHub repo. I set up a GitHub action to create a NuGet package and push it to my private NuGet registry on GitHub.
The build process is working fine but getting stuck at NuGet push because it's unable to find the directory where the NuGet package is created. The error I get is:
Run dotnet nuget push "${GITHUB_WORKSPACE}/bin/Release/MyLibrary.Core.1.3.1.nupkg" --source "github" dotnet nuget push "${GITHUB_WORKSPACE}/bin/Release/MyLibrary.Core.1.3.1.nupkg" --source "github" shell: /usr/bin/bash -e {0} env: DOTNET_ROOT: /usr/share/dotnet error: Could not find a part of the path '/home/runner/work/my-core-library/my-core-library/bin/Release'.
Here's the yaml
file for this job:
name: Publish MyLibrary.Core NuGet to GitHub Packages
on:
pull_request:
branches: [ "master" ]
jobs:
build-pack-n-ship:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Create NuGet package
run: dotnet pack --configuration Release
- name: Add Package Source
run: dotnet nuget add source --username my_github_username --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/my_company_account/index.json"
- name: Publish to GitHub Packages
run: dotnet nuget push "${GITHUB_WORKSPACE}/bin/Release/MyLibrary.Core.${{ steps.get-version.outputs.version }}.nupkg" --source "github"
Any idea what maybe the cause and how to fix it?
UPDATE:
I added a line to run ls -l
as suggested in a comment. Here's what I get when that line executes:
ls -l
shell: /usr/bin/bash -e {0}
env:
DOTNET_ROOT: /usr/share/dotnet
total 12
drwxr-xr-x 10 runner docker 4096 Mar 27 18:37 MyLibrary.Core
-rw-r--r-- 1 runner docker 1114 Mar 27 18:37 MyLibrary.Core.sln
-rw-r--r-- 1 runner docker 269 Mar 27 18:37 README.md
You need to verify that the generated package location and its name is according to what the dotnet push
command expects.
As you're using the ubuntu-latest
runner, you may use Bash shell commands such as pwd
and ls
to verify the location and name.
According to your configuration, the generated package should be under ./bin/Release
directory.
Apart from that, you may also specify the target directory with dotnet pack
command like this:
dotnet pack --configuration Release --output target/
Now, the generated package will be under the target
directory.