Visual Studio / NuGet缺少引用 [英] Visual Studio/ NuGet missing references

查看:462
本文介绍了Visual Studio / NuGet缺少引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的解决方案的参考有一些问题,因为有人去弄乱了NuGet ...从源代码控制恢复,使项目无法载入,我不得不玩一下,终于得到加载。当我终于能够使我的项目正确加载(头痛之后),我有一个很大的实验性的麻烦来清理,现在没有任何建立。



Nuget认为我的依赖是安装的。 Visual Studio不同意。





我要做什么来使NuGet和Visual Studio相互同意?

解决方案

这不简单,但尝试以下步骤:


  1. 在包管理器控制台中还原您的nuget包

  2. 在记事本中打开csproj并检查路径是否正确。如果没有修复它们。

  3. 如果以上步骤在包管理器控制台中无法重新安装所有包。

  4. 如果项目打开,则卸载它,然后重新加载它。这迫使Visual Studio重新解析引用。

说明:



当nuget添加引用时,它会添加到csproj中,如下所示:

 <引用包含=Newtonsoft.Json> 
< HintPath> .. \packages\Newtonsoft.Json.4.5.9\lib\\\
et40\Newtonsoft.Json.dll< / HintPath>
< / Reference>

这意味着包号码在HintPath中。合并两个分支后,nuget版本号可能已更改。这将导致HintPath也应该更改为具有版本的正确路径。这就是为什么Visual Studio有问题找到它们。


I had some problems with my solution's references since somebody went and messed up NuGet... restoring from source control rendered the projects unloadable, and I had to play around a bit to finally get things to load. When I was finally able to get my projects to load properly (after one heck of a headache), I had a pretty big experimental mess to clean up, and now nothing builds.

Nuget thinks my dependencies are installed. Visual Studio disagrees.

What do I have to do to make NuGet and Visual Studio agree with each other?

解决方案

It is not simple but try following steps:

  1. In package manager console restore your nuget packages
  2. Open csproj in notepad and check if paths are correct. If not repair them.
  3. If above steps won`t work in package manager console reinstall all your packages.
  4. If the project is open, Unload it, then Reload it. This forces Visual Studio to re-resolve the references.

Explanation:

When nuget add reference it add it in csproj like below:

<Reference Include="Newtonsoft.Json">
  <HintPath>..\packages\Newtonsoft.Json.4.5.9\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>

Which means that package number is in HintPath. After you merge two branches, the nuget version numbers probably changed. This causes that HintPath should also be changed to proper path with version. That is why Visual Studio has problems to find them.

这篇关于Visual Studio / NuGet缺少引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆