GitHub 操作 dotnet build 找不到包

GitHub Actions dotnet build Unable to find package

我有一个 .NET CI ins GitHub 操作。在将 Dapper.FluentMap 添加到项目之前,GitHub 操作可以正常运行。

GitHub 操作失败于:

- 名称:使用 dotnet 构建

运行: dotnet build --configuration Release

如何使用 NuGet Dapper.FluentMap 依赖项构建 GitHub 操作?

我现在在 GitBub 操作中遇到错误:

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

我的 Yaml 文件

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

这似乎是最近的错误/问题,正如 here and here 在 GitHub 上所报告的那样。

您可以通过在步骤中手动添加 nuget.org 作为源来解决此问题:

[...]
    - 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
[...]