.net-core - 如何防止 nuget 在 Visual Studio 2017 中打开解决方案后冗余恢复包

标签 .net-core visual-studio-2017 nuget

每次我在 Visual Studio 2017 中打开使用 Net.Core SDK 的解决方案时,它都会恢复包。即使我关闭解决方案并再次打开它,这种情况总是会发生。

为什么它不本地跟踪计算机上存在哪些 nuget 包?

我可以让它表现得更符合逻辑吗?首先在本地检查包是否存在,然后仅在找不到包时才恢复它?

最佳答案

Question: How to prevent nuget from redundantly restoring packages after opening solution in Visual Studio 2017

目前无法显式禁用自动恢复。检查以下线程以了解更多详细信息:

How do I disable restoring NuGet packages while starting the solution

The restore you are seeing there is Auto-Restore which will only run on SDK based projects. https://learn.microsoft.com/en-us/nuget/consume-packages/package-restore#automatic-restore-in-visual-studio

There is currently no way to disable auto-restore explicitly but you can disable restore itself. Note that this will disable all restore (on build/rebuild & solution right click restore)

此外,您不需要禁用它,请检查以下另一个原因:

Question: Can i make it to behave more logically and first to check it locally for the package presence and to restore it only if it can not be found?

nuget 现在所做的正是您想要它做的。检查:

Forcing restore from package sources :

By default, NuGet restore operations use packages from the global-packages and http-cache folders.

因此,打开解决方案时看到的恢复只是检查全局包中是否存在包,如果不存在,则 nuget start 恢复包。如果包存在,nuget不会执行恢复操作。而且检查时间很短,大约几十ms。您不必太担心。

希望这有帮助。

关于.net-core - 如何防止 nuget 在 Visual Studio 2017 中打开解决方案后冗余恢复包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53495491/

相关文章:

jenkins - 如何使用 Jenkins 自动创建 NuGet 包?

c# - 如何在 .Net Core 中使用 WebClient?

c# - 在 unix (nginx) 上托管时 .NET Core 中的 TimeZoneInfo

c# - 如何在.NET Core 3.1 WebAPI中托管Angular应用程序?

c# - 显示调试器未显示在 Visual Studio 2017 中

visual-studio-2017 - Resharper 'Ctrl Click' 不适用于 Visual Studio 2017

ios - Xcode 有包管理器吗? (如 NuGet)

.net-core - 安装 .NET Core 后运行 'dotnet run' 时无可执行输出

c# - 在 Visual Studio 2017 中通过设计器添加到 RDLC 报告的图表将不起作用

nuget - Visual Studio 2015 Nuget“没有工作文件夹映射”错误