0

I am using Visual Studio Code (VS Code) Editor for ASP.NET Core-5 Web API.

I have installed different packages in the VS Code without any error.

However, when I did:

dotnet run

I got this errors:

C:\Users\Kume\source\repos\MyApp\DDM.API.Core\API.Core.csproj : error NU1101: Unable to find package Microsoft.EntityFrameworkCore. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages

C:\Users\Kume\source\repos\MyApp\DDM.API.Core\API.Core.csproj : error NU1101: Unable to find package Microsoft.EntityFrameworkCore.Design. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages

C:\Users\Kume\source\repos\MyApp\DDM.API.Core\API.Core.csproj : error NU1101: Unable to find package Microsoft.EntityFrameworkCore.SqlServer. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages

C:\Users\Kume\source\repos\MyApp\DDM.API.Core\API.Core.csproj : error NU1101: Unable to find package Microsoft.EntityFrameworkCore.Tools. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages

How do I resolve this?

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Olugbenga
  • 63
  • 3
  • 8
  • 1
    It would appear that nuget.org is not among your NuGet sources. What happens when you run `dotnet nuget list source`? Did you change any NuGet settings? Are using Nuget.Config somewhere? What happens when you `dotnet restore`? See also [Common nuget configurations](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#config-file-locations-and-uses) at MS doc. – Zdeněk Jelínek Nov 27 '21 at 20:47

1 Answers1

3

Your best option is to create a Nuget.config file at the root of your solution and place the following content inside:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
      <clear /> <!-- (optional) this is for clear sources like default Offline repo -->
      <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>
  • I have three projects in the Solution. Do I put it in each project or the solution as a whole? – Olugbenga Nov 27 '21 at 20:59
  • In solution is better, cause apply for all projects – Osni Pezzini Junior Nov 28 '21 at 21:22
  • 1
    If you are copying the XML shared by @OsniPezziniJunior, either strip the comment or correct it from <!- (optional) this is for clear sources like default Offline repo -> to . It worked like a charm from me after I did this. – GuruKay Feb 13 '22 at 19:12