Search code examples
githubnugetgithub-actions

GitHub Actions dotnet build Unable to find package


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

Solution

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