visual-studio - 开箱即用的破损 Nuget 包引用

标签 visual-studio tfs nuget nuget-package-restore

与以下症状相同 Nuget Packages are there but missing References 但要复制的用例要简单得多:

  • 用户 A 将其代码 checkin TFS
  • 用户 B(或 C、D 等)第一次从 TFS 获取解决方案,或者进入一个全新的地方。

结果:Nuget 维护的所有引用 dll 都显示损坏的黄色三角形,即使在该线程推荐的“清除所有 NuGet 缓存”和“Update-Package -reinstall”黑客之后也是如此。关闭并重新打开 VS 和解决方案将不起作用,尽管在 Update-Package -reinstall 之后 dll 确实存在,正如所暗示的那样。

这是VS2017版本15.3.5。

更新:

结果发现“可用”是一个“.xml”文件,其扩展名在文件资源管理器中未正常显示。即,“.dll”文件丢失,并且 Update-Package -reinstall 无法恢复。

更新2:

Update-Package -reinstall 无法工作,因为无法添加引用(引用不可用)。以下是完整日志: 更新:解决后删除,查看历史记录,或者从https://pastebin.com/1e5axkTm查看。

当我查看日志时,我发现,

Package 'NUnit 3.6.1' does not exist in project 'MyProj'
Package 'NUnit 3.6.1' already exists in folder '\Path\To\MySolution\packages'
...
Update-Package : Failed to add reference to 'nunit.framework'.
  Reference unavailable.

我的解释是,因为nunit.framework DLL不在TFS中,因此对于从TFS获取解决方案的用户B(或C、D等)来说,它在本地不可用,但是Update-Package -reinstall 没有注意到并且无法修复问题。因此会导致更多问题 - 无法添加引用(引用不可用)。

更新3:

感谢@LeoLiu-MSFT 和@starianchen-MSFT 的帮助,在源代码管理中不包含包文件夹解决了上述问题。 “Update-Package -reinstall”现在没有任何错误(如果您需要仔细检查,https://pastebin.com/e8TpXg2D)

最终更新:

是的,@LeoLiu-MSFT 和 @starianchen-MSFT,不包括源代码管理中的包文件夹关键!请回答以便我可以接受。

以下问题是由完全不同的问题引起的 - All MS VS References broken after project moved .

However, even after above, and use "NuGet Package Restore" to download them, I'm still getting the following:

Error This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Selenium.WebDriver.ChromeDriver.2.28.0\build\Selenium.WebDriver.ChromeDriver.targets.

  • I've checked the page of http://go.microsoft.com/fwlink/?LinkID=322105, the "Allow NuGet to download missing packages" and "Automatically check for missing packages during build in Visual Studio" have already been checked.
  • I've removed the packages\Selenium.WebDriver.ChromeDriver.2.28.0 folder several times, and did "NuGet Package Restore" several times as well, but the problem remains.

What's the proper fix?

最佳答案

Broken Nuget Packages References out of the box

根据您在UPDATE2中的错误日志:

Package 'NUnit 3.6.1' does not exist in project 'MyProj'
Package 'NUnit 3.6.1' already exists in folder '\Path\To\MySolution\packages'

您似乎在源代码管理中添加了packages文件夹。

要解决此问题,您应该从源代码管理中删除该包文件夹。您只需将 packages.config (或 project.json)检查到源代码管理,当其他用户 B 从那里获取解决方案时TFS,然后使用命令行Update-Package -reinstall,VS/NuGet会先恢复包,然后将dll重新安装到项目中。

关于visual-studio - 开箱即用的破损 Nuget 包引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47839210/

相关文章:

visual-studio - 与 VS2010 集成的基于文件的版本控制系统

visual-studio - 除了解决方案资源管理器之外的 Visual Studio(带有 TFS)历史记录?

c# - 如果只有最后一次构建通过 TFS 插件失败,则 TFS 成功构建警报电子邮件

.net-core - 如何使 dotnet publish 命令使用私有(private) Nuget 源

visual-studio - VS 说 "You have 1 deprecated package versions installed",但哪一个?

c++ - Windows 上的 Objective C

c# - Visual Studio 2017在调试时尝试使用IP连接到本地Mysql

tfs - Sonarqube 未测量来自 TFS 2017 Build 的代码覆盖率

msbuild - 无法为指定的 URI 添加部分,因为它已在包中

visual-studio - Visual Studio 2012 的蓝色主题,如 2010