Hossam Barakat Thoughts about ASP.NET, mobility, and technology.

Fix error NU1101: Unable to find package. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages

I use Azure DevOps as my build pipelines for a lot of projects, I have faced the following error recently:

Unable to find package AutoFixture. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages

I found that there are two easy ways to fix this error hence I am writing them here as self-reminder for the solutions.

Option A: Add nuget.config

Add a nuget.config to the solution directory with resolve the issue

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

Option B: Add Restore Packages step to the build pipeline

Add the following dotnet restore step to the build pipeline with includeNuGetOrg: true would resolve the issue

- task: [email protected]
  displayName: dotnet restore
  inputs:
    command: restore
    projects: '$(serviceLocation)/**/*.csproj'
    includeNuGetOrg: true

Remember to add the private package feeds if you are using any.

I hope that helps.

comments powered by Disqus