Nuget.exe 命令 CLI 无法识别

问题描述 投票:0回答:1

我想添加 feed 以将我的 nuget 包作为工件推送到 Azure Devops。我已按照 Microsoft 文档中提到的所有步骤将我的 nuget 包推送到 Azure Devops。我已经下载了 nuget.exe CLI,它位于我生成/构建项目 nuget 包的同一文件夹中。但是,为什么我收到以下错误,并且我到处搜索但找不到任何答案:-

构建nuget包和nuget.exe CLI文件夹路径:-

C:\Users\Desktop\MyProjects\ProjectName> Under this folder I have following files
   --nuget.exe 
   --AutoOnWeb.Messaging.Helpers.2.1.0.nupkg

要执行的命令(添加此提要):

Path: C:\Users\Desktop\MyProjects\ProjectName>    
    nuget.exe sources Add -Name "AutoShop.Messaging.Helpers" -Source "https://pkgs.dev.azure.com/HelpersLibrary/_packaging/AutoShop.Messaging.Helpers/nuget/v3/index.json"

错误:-

nuget.exe : The term 'nuget.exe' 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 sources Add -Name "InfrastructureMessagingHelpers" -Source  ...
+ ~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (nuget.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

我已经下载并安装了所有必需的框架库。

谢谢,

powershell azure-devops nuget nuget-package
1个回答
0
投票

Nuget.exe 命令 CLI 无法识别

因为NuGet是一个外部命令,在任意目录下都无法被Windows识别,这就是它不被识别的原因。

要解决此问题,您应该在 NuGet.exe 所在的路径中键入“NuGet”或“NuGet.exe”。对于您的情况,您可以在调用 nuget.exe 时将路径切换到

C:\Users\Desktop\MyProjects\ProjectName>

或者,您可以从 NuGet.org 下载 NuGet.exe(不是 VSIX),然后 将 NuGet.exe 的本地路径设置到路径环境变量中。在这种情况下,您可以直接在 powershell 脚本中调用 nuget.exe。

希望这有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.