开箱即用的损坏的 Nuget 包引用
Broken Nuget Packages References out of the box
症状与
但要复制的用例要简单得多:
- 用户 A 将 his/her 代码签入 TFS
- 用户 B(或 C、D 等)第一次从 TFS 获取解决方案,或者进入一个全新的地方。
结果:Nuget 维护的所有引用 dll 显示损坏的黄色三角形,即使在该线程推荐的 "Clear All NuGet Cache" 和“Update-Package -reinstall
”黑客攻击之后也是如此。关闭并重新打开 VS 和解决方案将不起作用,尽管 dll 确实存在,如提示的那样,在 Update-Package -reinstall
之后。
这是VS2017版本15.3.5。
更新:
结果 "available" 是一个“.xml
”文件,其扩展名在文件资源管理器中未正常显示。即,“.dll
”文件丢失且未被 Update-Package -reinstall
恢复。
更新2:
Update-Package -reinstall
不工作,因为它 failed to add reference
(Reference unavailable
)。这里是完整日志:更新:解决后删除,查看历史记录,或从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
没有注意到也无法解决问题。因此在未来造成更多问题——failed to add reference
(Reference unavailable
).
更新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到项目中。
症状与
- 用户 A 将 his/her 代码签入 TFS
- 用户 B(或 C、D 等)第一次从 TFS 获取解决方案,或者进入一个全新的地方。
结果:Nuget 维护的所有引用 dll 显示损坏的黄色三角形,即使在该线程推荐的 "Clear All NuGet Cache" 和“Update-Package -reinstall
”黑客攻击之后也是如此。关闭并重新打开 VS 和解决方案将不起作用,尽管 dll 确实存在,如提示的那样,在 Update-Package -reinstall
之后。
这是VS2017版本15.3.5。
更新:
结果 "available" 是一个“.xml
”文件,其扩展名在文件资源管理器中未正常显示。即,“.dll
”文件丢失且未被 Update-Package -reinstall
恢复。
更新2:
Update-Package -reinstall
不工作,因为它 failed to add reference
(Reference unavailable
)。这里是完整日志:更新:解决后删除,查看历史记录,或从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
没有注意到也无法解决问题。因此在未来造成更多问题——failed to add reference
(Reference unavailable
).
更新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到项目中。