【问题标题】:The NuGet Installer task used in TFS 2017 build definition fails to clear the global-packages folder with an errorTFS 2017 构建定义中使用的 NuGet 安装程序任务无法清除 global-packages 文件夹并出现错误
【发布时间】:2019-09-05 10:47:06
【问题描述】:

我们在 TFS 2017 中创建了一个构建定义,它构建了一个依赖于我们的一些 NuGet 包的 .net 解决方案,在编译过程中,该解决方案从位于此的包(全局包)文件夹中恢复 NuGet 包路径 %userprofile%\.nuget\packages 而不是从我们的内部提要下载最新的。

我在page 看到了一个命令,以避免使用 global-packages 文件夹,但是当我在 NuGet 安装程序任务中添加 nuget locals global-packages -clear 参数时,用于恢复 nuget 包,任务失败并显示以下内容错误提示 unknown option -Clear

我在任务中使用的 NuGet 版本是 3.5.0。

2019-09-05T09:27:18.8819742Z ##[section]Starting: NuGet restore $(build.sourcesdirectory)/IntelliSuiteService.sln
2019-09-05T09:27:18.8819742Z ==============================================================================
2019-09-05T09:27:18.8819742Z Task         : NuGet Installer
2019-09-05T09:27:18.8819742Z Description  : Installs or restores missing NuGet packages
2019-09-05T09:27:18.8819742Z Version      : 0.2.31
2019-09-05T09:27:18.8819742Z Author       : Microsoft Corporation
2019-09-05T09:27:18.8819742Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)
2019-09-05T09:27:18.8819742Z ==============================================================================
2019-09-05T09:27:19.4601187Z [command]C:\Windows\system32\chcp.com 65001
2019-09-05T09:27:19.4757465Z Active code page: 65001
2019-09-05T09:27:19.5069958Z Detected NuGet version 3.5.0.1938 / 3.5.0
2019-09-05T09:27:19.5226206Z SYSTEMVSSCONNECTION exists true
2019-09-05T09:27:19.5226206Z [command]F:\Builds\NextGen_Gated\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.31\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe restore -NonInteractive F:\Builds\NextGen_Gated\2\s\SuiteService.sln -NoCache nuget locals global-packages -Clear
2019-09-05T09:27:20.1007732Z Unknown option: '-Clear'
2019-09-05T09:27:20.1163983Z ##[error]Error: F:\Builds\NextGen_Gated\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.31\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe failed with return code: 1
2019-09-05T09:27:20.1163983Z ##[error]Packages failed to install
2019-09-05T09:27:20.1320334Z ##[section]Finishing: NuGet restore $(build.sourcesdirectory)/SuiteService.sln

【问题讨论】:

  • 您需要单独运行它,而不是使用 nuget restore 命令。
  • @ShaykiAbramczyk 单独但与哪个任务?任何批处理任务都可以吗?
  • Yes :) 或者只是登录到您的代理机器并在命令行上运行一次。
  • 它给了我未知命令:'nuget' 错误,当我在 cmd "F:\srp\NuGet\3.5.0\NuGet.exe nuget locals global-packages -clear 中提供以下命令时"
  • 不用nuget试试(因为你已经给了exe路径)

标签: tfs azure-devops nuget-package nuget-package-restore


【解决方案1】:

您应该将该命令与nuget restore 命令分开运行。

您可以登录到代理机器并从命令行运行它,也可以在构建中添加运行命令的命令行或批处理任务。

【讨论】:

    猜你喜欢
    • 2017-10-20
    • 2014-07-11
    • 2011-11-27
    • 1970-01-01
    • 1970-01-01
    • 2017-11-23
    • 1970-01-01
    • 2019-06-24
    • 2018-04-01
    相关资源
    最近更新 更多