c# - Visual Studio : how to add nuget packages as references when doing "Restore NuGet packages"

标签 c# visual-studio

我已经使用 packages.config 中存在的“恢复 NuGet 包”下载了所有包

但是,它们没有出现在引用中,所以 VS 不知道它们。

有没有办法自动将它们添加到引用列表中?可能只需一步?

enter image description here

最佳答案

引用作为项目文件的一部分进行跟踪,并且通常作为 NuGet 包初始安装的一部分添加。恢复包只会下载它们。

这意味着您似乎需要重新安装那些缺少引用的特定包。

为此,run the Update-Package command in the Package Manager Console with the -reinstall flag on it .

Update-Package <package_name> -ProjectName MyProject -reinstall

您可以选择 add the -Version flag如果您需要坚持使用不是最新的版本,只需使此版本号与存储在您的 packages.config 文件中的版本号相匹配即可。

或者,重新安装给定项目的所有包:

Update-Package -Reinstall -ProjectName <project_name>

关于c# - Visual Studio : how to add nuget packages as references when doing "Restore NuGet packages",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46107479/

相关文章:

没有路径的 Windows 快捷方式

visual-studio - 使用源代码管理

c# - 处理嵌套属性值

c# - 可空类型是否适合我的情况?

c++ - c/c++ 中的 winsock.h post 请求

.net - VS2008 - 为版本号添加字母(即 1.1.1.12-Dev)

visual-studio - 安装 VS 2008 SP1 失败

c# - AngularJS 和 Web Api 社交身份验证

c# - 如何从 jwt token 中获取 "exp"并与当前时间进行比较以检查 token 是否已过期

c# - 在 .NET 4.0 (C#) 中动态实现接口(interface)