question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet restore is unable to find common .NET packages since switching to .NET 5.0

See original GitHub issue

Description

I switched from .NET Core 3.1 to .NET 5 and since then the action fails to restore common .Net packages.

Details

Error messages on installing dependencies “dotnet restore Project.sln”. The error does not occur when the command is executed locally. No custom nuget repository is used and the packages should be available.

error NU1101: Unable to find package System.Memory. No packages exist with this id in source(s): github [/home/runner/work/Project/Project.sln]
error NU1101: Unable to find package System.Numerics.Vectors. No packages exist with this id in source(s): github [/home/runner/work/Project/Project.sln]
error NU1101: Unable to find package NETStandard.Library. No packages exist with this id in source(s): github [/home/runner/work/Project/Project.sln]
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
      uses: actions/setup-dotnet@v1.7.2
      with:
        dotnet-version: 5.0.100
    - name: Install dependencies
      run: dotnet restore Project.sln
    - name: Build
      run: dotnet build Project.sln --configuration Release --no-restore
    - name: Test
      run: dotnet test Project.sln --no-restore --verbosity normal

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:11
  • Comments:11

github_iconTop GitHub Comments

5reactions
csinkerscommented, Oct 7, 2021

Adding a NuGet.config is a better way to fix it, e.g.

<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>
1reaction
csinkerscommented, Oct 8, 2021

The details for why it broke and why a nuget.config fixes it are pretty complicated, if you follow the links from this issue to the various ones that got raised in the github actions, .net core, and nuget repositories you can get the whole story.

I think it boiled down to a change in some nuget rule that ended up (sporadically) breaking things for every project that didn’t have an explicit nuget config, and while the nuget change would normally be benign, some detail of the GitHub actions environment meant it caused issues.

Because it was only partially the fault of either project I think neither took responsibility for fixing it, so we all have to be explicit about our nuget sources using a config now 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet restore command - .NET CLI
To restore the dependencies, NuGet needs the feeds where the packages are located. Feeds are usually provided via the nuget.config configuration ...
Read more >
Troubleshooting NuGet Package Restore in Visual Studio
This article focuses on common errors when restoring packages and steps to resolve them. Package Restore tries to install all package ...
Read more >
NuGet Error NU1102
NET SDK error NETSDK1004, which occurs when the project.assets.json file is not found. NuGet Package Restore. See an overview of how NuGet ...
Read more >
NuGet Package Restore
For more information, see PackageReference in project files. .NET Core 2.0 and later dotnet build and dotnet run commands restore packages ...
Read more >
Troubleshoot .NET tool usage issues - .NET CLI
Possible reasons for this include: * You misspelled a built-in dotnet command. * You intended to execute a .NET program, but dotnet-xyz does...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found