【问题标题】:nuget.exe in Visual Studio 2019Visual Studio 2019 中的 nuget.exe
【发布时间】:2020-02-03 20:00:00
【问题描述】:

我的机器上有 VS2017 和 VS2019。我在 VS2019 解决方案资源管理器中缺少很多 nuget 引用(黄色图标)。我试过恢复 Nuget 包,我看到了:

All packages are already installed and there is nothing to restore.
Time Elapsed: 00:00:00.0560466
========== Finished ==========

我进入包管理器控制台并尝试执行以下操作:

nuget restore MySolution.sln

得到一个

nuget : The term 'nuget' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path 
is correct and try again.
At line:1 char:1

我在硬盘上环顾四周,只看到 nuget.exe 存在于 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\SqlChangeAutomation\OctoPack\build\NuGet.exe 中

为什么2019年也不存在?

谢谢

【问题讨论】:

  • 因为Visual Studio可以简单的使用客户端库nuget.org/packages/NuGet.Client,不一定是nuget.exe。
  • 有时,如果您在项目的“参考”选项下单击缺少的参考(黄色参考),Visual Studio 会“看到”它们。
  • 据我所知,如果你想在包管理控制台中使用nuget.exe,你应该设置nuget.exe的路径,你可以从Marcus的链接下载到环境变量的PATH .如果答案确实有帮助,请考虑接受。这只是一个提醒:)
  • 包管理器控制台,使用powershell命令docs.microsoft.com/en-us/nuget/reference/powershell-reference

标签: c# visual-studio-2017 nuget visual-studio-2019


【解决方案1】:

您可以从here 下载 Nuget.exe。

将 Nuget.exe 复制到您保存工具的位置。然后我建议在 PATH 系统变量中输入保存 Nuget.exe 的位置。

我会尝试清除 nuget 缓存。您可以使用以下命令执行此操作:

nuget locals all -clear

这可确保再次下载所有包。

您不能在包管理器控制台中调用 Nuget.exe。为此,您必须打开一个控制台会话并切换到您的解决方案目录以执行所需的命令。

nuget restore MySolution.sln

最重要的是,稍微浏览一下 Nuget 文档页面也会很有帮助。你可以找到他们here

我希望我能帮助你一点,并引导你走上一条可能的道路。

最好的祝福

【讨论】:

    猜你喜欢
    • 2020-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-09
    • 2019-03-09
    • 2021-10-04
    • 2023-01-15
    • 2020-05-17
    相关资源
    最近更新 更多