首页 > 解决方案 > 尝试通过 GitHubActions 发布到 GitHub 包时出现不正确的路径和无 API 错误

问题描述

一直卡在这个问题上,似乎是一个接一个的问题,只是试图让 GitHub Actions 将一个 nuGet 包发布到 GitHub 包,文档真的很难找到,似乎没有给出任何明确的例子

这是我之前的问题(只是为了上下文以防它有帮助) 我无法获得 gitHub 操作来将我的包构建发布到 nuget.pkg.github

但现在,我得到以下信息:

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'.

这是我的完整 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"

这是构建结果:

在此处输入图像描述

标签: githubgithub-actions

解决方案


dotnet nuget遗憾的是并不总是按预期工作,并且有返回误导性错误消息的习惯。真让人生气。

尝试nuget/setup-nuget@v1在您的工作流程中添加一个步骤并使用nuget.exe push而不是dotnet nuget push. 这可能会解决问题,或者至少会给您提供更有用的错误消息。


推荐阅读