top of page

Issues faced and fixes while publising GitHub 'package' with NuGet



While recently writing a Github action on creating and publishing NuGet package for my Github repository, I encountered some errors and while it did take a while for me fix all of them, I thought of aggregating all in here and share. Hope this might help someone.


Issue 1: Cannot find commit b4f39e5 Added calculator engine code and package action. Please ensure that the repository is an unshallow clone with `git fetch --unshallow`

Fix:

I was using the actions/checkout@v2 without passing the parameter 'fetch-depth'. By default, as mentioned in their official repo, only a single commit is fetched which creates a shallow fetch.







As outlined in the error, we need to ensure that all the history etc. are fetched (a.k.a unshallow) for which the parameter 'fetch-depth' needs to be passed as 0.


Issue 2: Could not find a part of the path '/home/runner/work/packagemanagement/packagemanagement/nupkg'

Fix:

This took most of my time to exactly find out where my .nupkg file was and provide that path accordingly (and since this was not a self-hosted runner, I couldn't get into the machine and find this out).

Eventually, I temporarily added an extra step above it to recursively find out the locations of the files and folders on the github runner machine under /home/runner/work.




The output of this indicated that the ".nupkg" was inside /home/runner/work/ itself and the folder was not needed. Good point to note this for debugging such issues.


Issue 3: Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.

Fix:

While I did create the PAT and added the needed permissions and scope as required, I was continously facing the same issue. I reverted this anyways, to use GITHUB_TOKEN as a recommened option and the workflow was succeeded.


While above got fixed with GITHUB_TOKEN which was anyways recommended option, I'm still curious to know why the PAT didn't work. If I get to it, I'll surely post this in my comments (or if you have any thoughts on this, please do share in the comments section).


Hope this helps and in case if you have any better ways than mentioned above to go about it, would love to hear that. Thanks!

4 views0 comments

Comments


bottom of page