24

In Terminal of Visual Studio Code, when I try to run:

dotnet add package MicrosoftOfficeCore --version 15.0.0

I get the following error on Visual Studio Code terminal:

error: NU1100: Unable to resolve 'MicrosoftOfficeCore (>= 15.0.0)' for 'net5.0'
error: Package 'MicrosoftOfficeCore' is incompatible with 'all' frameworks in project

Do anyone have an idea?

ouflak
  • 2,458
  • 10
  • 44
  • 49
Ghislain Bruyere
  • 373
  • 1
  • 2
  • 10

1 Answers1

90
  1. Try clearing the NuGet cache using dotnet nuget locals all --clear, and then try to add your package.

  2. If that doesn't work, try deleting the NuGet.config file present inside C:\Users\<username>\AppData\Roaming\NuGet directory, and then restore it using dotnet restore command. Try adding your package after this.

The above solution works irrespective of whichever .NET version you're using.

Yash Gupta
  • 1,807
  • 15
  • 21
  • 4
    1. Same error 2. Works perfectly, thank you very much – Ghislain Bruyere Jul 07 '21 at 11:20
  • 1
    Thanks a lot, we had the second problem with a fresh install of dotnet sdk 5.0.400. – Benni Sep 02 '21 at 09:32
  • 11
    worked perfect, in my case `` was missing as a package source in the default nuget.config created by the installation. – baywet Sep 07 '21 at 19:36
  • I had problem #2 from a net6.0 install using official scripted installer from https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script. same missing line as @baywet – user1169420 Aug 25 '22 at 19:29
  • Got the error when creating a new webapi after installing .NET 7.0. Deleting the NuGet.config and "dotnet restore" fixed it. – Reza Taba Nov 28 '22 at 16:39
  • Step number 2 fixed it for us, too. First step had no effect on our machine. – okirmis Jan 27 '23 at 13:20
  • 1
    Step #2 works, but `dotnet restore` may not work. In this case, simply re-run command you were trying to run. (e.g. dotnet install, dotnet add, etc.) Then, it will automatically add missing configuration as outlined by @baywet above. – jkim Feb 12 '23 at 20:45