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

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

在 Visual Studio 代码的终端中,当我尝试 运行:

dotnet add package MicrosoftOfficeCore --version 15.0.0

我在 Visual Studio 代码终端

上收到以下错误
error: NU1100: Unable to resolve 'MicrosoftOfficeCore (>= 15.0.0)' for 'net5.0'
error: Package 'MicrosoftOfficeCore' is incompatible with 'all' frameworks in project

你有什么想法吗?

非常感谢。

  1. 尝试使用 dotnet nuget locals all --clear 清除 NuGet 缓存,然后尝试添加您的包。

  2. 如果这不起作用,请尝试删除 C:\Users\<username>\AppData\Roaming\NuGet 目录中的 NuGet.config 文件,然后使用 dotnet restore 命令恢复它。在此之后尝试添加您的包裹。