nuget - 如何解决“无法找到包”nuget错误
问题描述
正在为依赖于作为项目参考添加的另一个项目 (B.csprojec) 的项目 (A.csproj) 创建 nuget pkg。
这是 .nuspec ,
<?xml version="1.0"?>
<package >
<metadata>
<id>A.Client</id>
<title>A.Client</title>
<description>HttpClient and Models for calling the A Microservice.</description>
<version>1.0.2</version>
<authors></authors>
<owners></owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>.</copyright>
<tags></tags>
<dependencies>
<group targetFramework=".NETFramework4.5">
<dependency id="Newtonsoft.Json" version="9.0.1" exclude="Build,Analyzers" />
// <dependency id="B" version="1.0.0"/> tried this but same error
</group>
<group targetFramework=".NETStandard2.0">
<dependency id="Newtonsoft.Json" version="9.0.1" exclude="Build,Analyzers" />
// <dependency id="B" version="1.0.0"/> tried this but same error
</group>
</dependencies>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System.Net.Http" targetFramework=".NETFramework4.5" />
</frameworkAssemblies>
</metadata>
<files>
<file src="bin\$configuration$\netstandard2.0\A.dll" target="lib\netstandard2.0" />
<file src="bin\$configuration$\net45\A.dll" target="lib\net45" />
</files>
</package>
我用了
nuget pack A.nuspec -Properties configuration=debug
生成包。但是,当我尝试在 c.csprojc 中使用此包时,出现以下错误
Severity Code Description Project File Line Suppression State
Error NU1101 Unable to find B. No packages exist with this id in source(s): Local Package source, Microsoft Visual Studio Offline Packages, nuget.org, Package source
我错过了什么 ?
解决方案
包源离线!!
我在我的系统上安装了VS2017专业版,打开一个已有的项目,发现缺少多个包。我尽我所能,没有看包源!
我正在写这个答案,因为我尝试了以下解决方案,但它们都没有奏效:
- 清除缓存
- 恢复或重新安装软件包
- 更改目标框架
- 更新 Nuget 包管理器
解决方案:
步骤 01.转到包管理器设置(工具 > Nuget 包管理器 > 包管理器设置)
步骤02。检查包源。可以看到,包源在这里已经下载了SDK/nugets/packages。我不知道原因,但我的 Visual Studio 系统安装中缺少来自 nuget.org 的在线包源。
步骤 03. 安装 nuget.org 作为包源,然后“清除所有 Nuget 缓存”,然后恢复包。错误会消失。
名称:nuget.org(或如你所愿) 来源:https ://api.nuget.org/v3/index.json
推荐阅读
- haskell - 导入模块时输入“模块”解析错误
- regex - Google 表单中不区分大小写的正则表达式:是否允许?
- reactjs - 在 fetch 方法从服务器接收令牌之前运行 React 渲染
- mysql - mysql,检索没有收到我请求的学生
- django - 在 aws lambda 上使用 django 和 sqlite
- python - 在矩阵中找到最大值的索引(python)
- mysql - MySQL 使用什么文件系统?
- r - R 使用分类变量和交互项对线性回归的嵌套横截面进行可视化
- python - 在先前构建的模型上使用 predict_proba 时出现 TypeError
- sparql - 如何使用 DBPEDIA 的 SPARQL 以简单的方式获取有关一个国家/地区的资本、货币、语言、人口等信息