error: NU1100: Unable to resolve 'MicrosoftOfficeCore (>= 15.0.0)' for 'net5.0'
Asked Answered
D

3

36

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?

Dooryard answered 7/7, 2021 at 9:50 Comment(0)
S
121
  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.

Schoolboy answered 7/7, 2021 at 10:57 Comment(8)
1. Same error 2. Works perfectly, thank you very muchDooryard
Thanks a lot, we had the second problem with a fresh install of dotnet sdk 5.0.400.Harbor
worked perfect, in my case <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> was missing as a package source in the default nuget.config created by the installation.Chalybite
I had problem #2 from a net6.0 install using official scripted installer from learn.microsoft.com/en-us/dotnet/core/tools/…. same missing line as @ChalybiteOxa
Got the error when creating a new webapi after installing .NET 7.0. Deleting the NuGet.config and "dotnet restore" fixed it.Soap
Step number 2 fixed it for us, too. First step had no effect on our machine.Tubuliflorous
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 @Chalybite above.Inglis
This bug is still present in VS Version 17.10.2. Step #2 worked for me. Step #1 did not.Malign
H
4

You can check that whether you're having Nuget.config file in your root folder or not. If you don't have Nuget.config file, just create it and add the below code :-

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="NuGet" value="https://api.nuget.org/v3/index.json" />
    <!-- You can add additional sources as needed -->
  </packageSources>
</configuration>

Now, re-run the dotnet restore. This will definitely solve the error of NU1100

Herrah answered 14/12, 2023 at 6:0 Comment(0)
N
0

Adding this in 2024 as a new answer (VS 2022, .NET 8/9 etc). It is possible that you have a packageSourceMapping element in your global NuGet.config causing this behavior.

I'm unsure how this element was added in my case, as the NU1100 error appeared globally while I was working on a project, where between builds it suddenly started throwing the NU1100 errors. Reverting changes had no effect.

The offending element may look something like this:

  <packageSourceMapping>
    <packageSource key="Local">
        <package pattern="Lula.Extensions.Xunit" />
      </packageSource>
  </packageSourceMapping>

The NU1100 error you get includes

the following source(s) were not considered: [...] nuget.org.

Full erroneous "default" config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <bindingRedirects>
    <add key="skip" value="False" />
  </bindingRedirects>
  <packageManagement>
    <add key="format" value="0" />
    <add key="disabled" value="False" />
  </packageManagement>
  <packageSourceMapping>
    <packageSource key="Local">
        <package pattern="Lula.Extensions.Xunit" />
      </packageSource>
  </packageSourceMapping>
</configuration>

Fixed, proper default config

Using a config like the following should allow dotnet restore to work normally again. Note that you may have more legitimate package sources, but you shouldn't have a packageSourceMapping like above.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <bindingRedirects>
    <add key="skip" value="False" />
  </bindingRedirects>
  <packageManagement>
    <add key="format" value="0" />
    <add key="disabled" value="False" />
  </packageManagement>
</configuration>
Notion answered 26/7 at 13:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.