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 "bin/Release/MyPackage.1.2.0.nupkg" --source
"github"
error: Could not find a part of the path
'/home/runner/work/my-package/my-package/bin/Release'.
Here's the yaml file for this job:
name: Publish MyPackage 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: Get version
uses: kzrnm/get-net-sdk-project-versions-action#v1
id: get-version
with:
proj-path: MyProject/MyProject.csproj
- name: Add Package Source
run: dotnet nuget add source --username MY_USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/MY_ORGANIZATION/index.json"
- name: Publish to GitHub Packages
run: dotnet nuget push "bin/Release/MyProject.${{ steps.get-version.outputs.version }}.nupkg" --source "github"
I think I need to specify the location of the working directory before the
"bin/Release/MyProject.${{ steps.get-version.outputs.version }}.nupkg" --source "github" but I wasn't able to get it right.
BTW, the part where I get the version number for my NuGet package is working fine. So I know that's not where the problem is.
Any idea how I can fix this?
Related
I have a .NET CI ins GitHub Actions. Before added Dapper.FluentMap to the project, the GitHub Action was working without any errors.
GitHub Actions fails on:
- name: Build with dotnet
run: dotnet build --configuration Release
How can I build on GitHub actions using a NuGet Dapper.FluentMap dependency ?
I am now getting an error in GitBub Actions:
D:\a\esta-uploadmanagement\esta-uploadmanagement\BLL\BLL.csproj : error NU1101: Unable to find package Dapper.FluentMap. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\esta-uploadmanagement\esta-uploadmanagement\esta-uploadmanagement.sln]
D:\a\esta-uploadmanagement\esta-uploadmanagement\WebApp\WebApp.csproj : error NU1101: Unable to find package Dapper.FluentMap. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\esta-uploadmanagement\esta-uploadmanagement\esta-uploadmanagement.sln]
Failed to restore D:\a\esta-uploadmanagement\esta-uploadmanagement\WebApp\WebApp.csproj (in 316 ms).
Failed to restore D:\a\esta-uploadmanagement\esta-uploadmanagement\BLL\BLL.csproj (in 313 ms).
D:\a\esta-uploadmanagement\esta-uploadmanagement\DAL\DAL.csproj : error NU1101: Unable to find package Dapper.FluentMap. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\esta-uploadmanagement\esta-uploadmanagement\esta-uploadmanagement.sln]
Failed to restore D:\a\esta-uploadmanagement\esta-uploadmanagement\DAL\DAL.csproj (in 1 ms).
My Yaml file
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout#v2
- name: Set up .NET Core
uses: actions/setup-dotnet#v1
with:
dotnet-version: '5.0.x'
- name: Build with dotnet
run: dotnet build --configuration Release
- name: dotnet publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
This seems to be a recent bug / issue, as reported here and here on GitHub.
You can work around this issue by manually adding the nuget.org as source in a step:
[...]
- name: Set up .NET Core
uses: actions/setup-dotnet#v1
with:
dotnet-version: '5.0.x'
# new step
- name: Add nuget.org as nuget package source
run: dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org
- name: Build with dotnet
run: dotnet build --configuration Release
[...]
I am using another Git Repo as library, which uses a different .net Version and has missing Permissions to be build on Action.
How do i exclude this/all sub modules from being built ?
Error Codes being Produced:
error MSB3191: Unable to create directory "obj/Debug/". Access to the path '/home/runner/work/Repo/Project/Submodule/Folder/obj/Debug/' is denied.
error MSB3644: The reference assemblies for .NETFramework,Version=v2.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application...
Workflow File (dotnet.yml)
name: .NET
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: textbook/git-checkout-submodule-action#master
- name: Setup .NET
uses: actions/setup-dotnet#v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
been stuck on this for a long time now, seems to be one problem after the other, just trying to get GitHub Actions to publish a nuGet package to GitHub packages, documentations is really hard to find and doesnt seem to give any clear examples
This was my previous question (just for context incase it helps)
I cant get gitHub actions to publish my package build to nuget.pkg.github
but now, I am getting the following:
Run dotnet nuget push "bin/Release/Project.1.0.0.nupkg" --source "github"
warn : 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.
error: Could not find a part of the path '/home/runner/work/project/project/bin/Release'.
Here is my full yml
name: .NET Core
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Setup .NET Core
uses: actions/setup-dotnet#v1
with:
dotnet-version: 3.1.200
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
- name: nuGet publish
run: dotnet nuget add source https://nuget.pkg.github.com/name/index.json -n github -u uname -p password123 --store-password-in-clear-text
- name: nuGet pack
run: dotnet pack --configuration Release
- name: publish
run: dotnet nuget push "bin/Release/EurekaShared.1.0.0.nupkg" --source "github"
this is the build result:
dotnet nuget sadly doesn't always work as expected, and also has a habit of returning misleading error messages. It's infuriating.
Try adding a nuget/setup-nuget#v1 step to your workflow and use nuget.exe push instead of dotnet nuget push. That might either fix the problem or at least give you a more helpful error message.
I think the error is related with the part of the path to nupkg file, or file name. It could be issue of case, since Linux is case-sensitive.
Moreover, this workflow file is to publish just one package, i.e., EurekaShared.1.0.0.nupkg it won't work if your package is EurekaShared.1.0.2.nupkg
Perhaps you can give it a try by updating the last line in your YML file by using wildcard ** as follows:
run: dotnet nuget push /**/*.nupkg --source "github"
I also suggest that you secure your username and password in workflow file with GitHub encrypted secrets https://docs.github.com/en/free-pro-team#latest/actions/reference/encrypted-secrets
I have been trying for a few months now, just to get GitHub actions to push a build to the gitHub packages, everytime i come back, try something else, nothing seems to work and it isnt making any sense.
I have just seen a new link with more details added for gitActions here:
I got excited, clicked, and see more code than previous had:
// Step 1: Authenticate (if this is the first time) Note you must also pass --store-password-in-clear-text on non-Windows systems.
$ dotnet nuget add source https://nuget.pkg.github.com/xxxxx/index.json -n github -u xxxxx -p GH_TOKEN [--store-password-in-clear-text]
// Step 2: Pack
$ dotnet pack --configuration Release
// Step 3: Publish
$ dotnet nuget push "bin/Release/myproject.1.0.0.nupkg" --source "github"
so, i went to my yml page (all within GitHub) and noticed the format is a little different... they are missing the "- name: xxx" and "run: xxx"
so, i updated... here is my full yml
name: .NET Core
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Setup .NET Core
uses: actions/setup-dotnet#v1
with:
dotnet-version: 3.1.101
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
- name: nuGet publish
run: dotnet nuget add source https://nuget.pkg.github.com/xxxx/index.json -n github -u xxxx-p GH_TOKEN [--store-password-in-clear-text]
- name: nuGet pack
run: dotnet pack --configuration Release
- name: publish
run: dotnet nuget push "bin/Release/projectname.1.0.0.nupkg" --source "github"
now, i thought maybe it would complain about password or something, but instead, im just getting this error: (i.e. "error: Unrecognized command or argument 'add'")
I am at a total loss and have no idea what and how to do this.... it builds fine all in gitHub, my package location is in GitHub, what am i doing so wrong?
EDIT:
thank you #ColinM after adjusting the yml above and just changin the version to 3.1.200, it now gets further, however, getting the following
Password encryption is not supported on .NET Core for this platform. The following feed try to use an encrypted password: 'github'. You can use a clear text password as a workaround
when running this line
Run dotnet nuget add source nuget.pkg.github.com/myname/index.json -n github -u myname -p abc123"
As per the MSDN documentation for dotnet nuget source add, this is available only from SDK 3.1.200 onwards; whereas you're currently using 3.1.101.
Update your YAML file to install an SDK version equal to or greater than 3.1.200
I have the following action on Github actions that automatically packs and deploy a package to nuget.org every time a PR gets merged into master.
name: Nuget Deploy
on:
push:
branches: [ master ]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout#v2
- name: Setup .NET Core
uses: actions/setup-dotnet#v1
with:
dotnet-version: 3.1.101
- name: Generate Nuget package
run: dotnet pack
working-directory: DateOverride
- name: Deploy to nuget.org
run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_DEPLOY_KEY }} -s https://api.nuget.org/v3/index.json
working-directory: DateOverride/DateOverride/bin/Debug
But I would like that it was not run if my update is only a README.md update, is it possible to do so?
I'd think the paths-ignore setting should help:
on:
push:
branches:
- master
paths-ignore:
- '**/README.md'
You might want to combine your current GitHiub Action with another like MarceloPrado/has-changed-path
This action outputs whether a path or combination of paths has changed in the previous commit.
[This] action is meant to be used inside your job steps, not at the root of your workflow file
Or (opposite filter): dorny/paths-filter
With this Github Action you can execute your workflow steps only if relevant files are modified.