NUGet安装提示:NU1100
提示:这里简述项目相关背景:
例如:在安装nuget包提示版本信息有误无法解析,或者安装失败
问题描述
例如:在 Visual Studio Code 的终端中,当我尝试运行时:
dotnet add package MicrosoftOfficeCore --version 15.0.0
Visual Studio Code 终端上收到以下错误
error: NU1100: Unable to resolve ‘MicrosoftOfficeCore (>= 15.0.0)’ for ‘net5.0’
error: Package ‘MicrosoftOfficeCore’ is incompatible with ‘all’ frameworks in project
或者Visual Studio 安装Nuget包源
提示
error: NU1100:
error: NU1100: Unable to resolve ‘MicrosoftOfficeCore (>= 15.0.0)’ for ‘net5.0’
原因分析:
在配置包源映射时源路径填写有问题
配置的包源映射需要检查
这个文件在电脑的C:\Users<username>\AppData\Roaming\NuGet
NuGet.Config
解决方案:
1、先用命令 $ dotnet nuget locals all --clear 清除NUGet包的缓存,在清楚缓存后在次尝试安装
2、如果第一种方法还是安装失败可以在C:\Users<username>\AppData\Roaming\NuGet 路径下将NuGet.Config删除在使用 $ dotnet restore 命令还原
如果学习练习项目中遇到可以忽略第一种方法,官方文档中
NU1100提到的两个解决方案也可进行参考