Search code examples
.netnugetgithub-actions

Github Action can't find the local source when using dotnet restore for nuget source


I'm trying to create a github action but I need to use an internal nuget package

 - name: "Setup Internal Packages"
    run: |
      dotnet nuget add source ${{ secrets.artifactory_url }} \
      -n myinternalpack \
      -u ${{ secrets.artifactory_user }} \
      -p ${{ secrets.artifactory_token }} \
      --store-password-in-clear-text

When I run this step it says Package source with Name: myinternalpack added successfully.

I even make sure with the next step to list sources:

Run dotnet nuget list source
Registered Sources:
1.  nuget.org [Enabled]
  https://api.nuget.org/v3/index.json
2.  myinternalpack  [Enabled]
    ***

But when I try to do a restore

dotnet restore ./sample-app --source myinternalpack --source https://api.nuget.org/v3/index.json

It says it doesn't exist.


Solution

  • So what I finally did was to put the nuget source credentials in a specific location.

    dotnet nuget update source myinternalpack \
          --configfile ./nuget.config \
          -s ${{ secrets.artifactory_url }} \
          -u ${{ secrets.artifactory_user }} \
          -p ${{ secrets.artifactory_token }} \
          --store-password-in-clear-text
    

    And when I did a restore, I selected where it was located.

    dotnet restore --configfile ./nuget.config