setup-dotnet: [Workaround found] NuGet errors in Windows build: NU1101 No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages

Description

I recently started getting failures in the Windows build for the dotnet action of my project, see https://github.com/csinkers/ualbion/runs/1574151895

Linux and macOS are still working fine, no project files / NuGet configurations have been changed since the last successful build. Sounds like it’s only looking for locally cached packages rather than using nuget.org.

Details

Yaml:

name: .NET Core

on: [push]

jobs:
  build:

    runs-on: ${{ matrix.os }}
    strategy:
        matrix:
            os: [macOS-latest, ubuntu-latest, windows-latest]

    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 3.1.100
    - name: Build with dotnet
      run: dotnet build --configuration Release src/UAlbion/UAlbion.csproj
    - name: Test with dotnet
      run: dotnet test ./src/ualbion.sln --configuration Release

Platform: windows-latest Version: .NET Core 3.1.100 Action link: https://github.com/csinkers/ualbion/actions Error messages:

D:\a\ualbion\ualbion\src\Core\UAlbion.Core.csproj : error NU1101: Unable to find package SerdesNet. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\ualbion\ualbion\src\UAlbion\UAlbion.csproj]
D:\a\ualbion\ualbion\src\Core\UAlbion.Core.csproj : error NU1101: Unable to find package Microsoft.CodeAnalysis.FxCopAnalyzers. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\ualbion\ualbion\src\UAlbion\UAlbion.csproj]
D:\a\ualbion\ualbion\src\Core\UAlbion.Core.csproj : error NU1101: Unable to find package System.Memory. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\ualbion\ualbion\src\UAlbion\UAlbion.csproj]
D:\a\ualbion\ualbion\src\Core\UAlbion.Core.csproj : error NU1102: Unable to find package Newtonsoft.Json with version (>= 12.0.2) [D:\a\ualbion\ualbion\src\UAlbion\UAlbion.csproj]

Was this a regression from previous behavior? – Yes

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 26
  • Comments: 17 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Found the fix, add this before the build (Ofcourse change the bumbo-web stuff to your own projectfolder/name): - name: Clean run: dotnet clean ./Bumbo-Web/Bumbo-Web.sln --configuration Release && dotnet nuget locals all --clear

Another thing that solved the issue for me was adding a nuget.config with the following to my project’s root:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <!--To inherit the global NuGet package sources remove the <clear/> line below -->
    <clear />
    <add key="nuget" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>

@jasonleenaylor, also you can try this step as workaround:

- run: dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org --configfile $env:APPDATA\NuGet\NuGet.Config

I’ve opened the issue for this bug in dotnet/core repository: https://github.com/dotnet/core/issues/5881

adding this helps

- name: Clean
  run: dotnet clean && dotnet nuget locals all --clear

I believe this is still a prevalent issue though that people will be looking for answers to. If not here, where should it be raised?